Sunday, May 29, 2011

Detect fake photos - error level analysis

Image processing was an area I was interested in, but wasn't interested enough to do some development with it. So while googling around, I found this neat way to detect fake photos. For example, consider a scenario, where I had two screen shots of the same screen, and both of them looked extremely real, except that the content was slightly different. There was no way I could distinguish between the two, unless I was a digital forensic expert.

But, after a looking around I found a neat tool, that which provides a nice analysis of photos. After that, a little bit of intuition and you can identify what part of the photos were faked out.

Here's how it works.
  1. Upload your images to imgur or any other image hosting service.
  2. Submit the link of the image to http://errorlevelanalysis.com/
  3. Next you will see a heat map of the image that highlights areas with error.
In the heat map, you can look see that the area that was edited looks a bit out of place. It's not entirely intuitive, but it's a neat starting point.

Here's a great read about the tool: http://www.techlikes.com/2010/09/23/software-tool-to-detect-fake-images.html - In the example, notice that there's a mistake - the fake photo error level analysis is swapped with the real one, compared to the fake and real photos.


Disclaimer: Don't go making accusations based on what you THINK is fake based on this tool, unless you are an expert. :)

    Thursday, May 26, 2011

    [SOLVED] This page contains the following errors: error on line x at column y: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error.

    Ever seen the error on $subject and looking for answers. Recently, I encountered the error when working with XML parsers in different browsers.

    Scenario: I was seeing no issue with Firefox but with Chrome I kept getting the error shown in $subject.

    Cause: After some debugging I found that this is due to the XML Parser used in chrome. After a certain query, if my result set was empty, my program was sending back and empty string ("") back to the browser. When this is parsed for XML, Chrome threw the error shown in $subject.

    Solution: If you are parsing for XML, send XML. When my result set was empty now I sent back an empty parent xml tag (i.e. <result></result>) and the problem was solved. Hope this helps anyone who comes across this issue.


    Wednesday, May 25, 2011

    Adding files recursively to svn for an already added directory

    A simple set of commands that's very effective and potentially allowed me to save about a half an hour of manual file adding for my friend Thilanga.

    Scenario: He had a set of files (around 100+) that were in different directories of an already added directory (referred to as root).

    Go to the root directory of the change and just type this command and you are done.
    $ svn st | grep ? | tr -s ' ' | cut -f2 -d ' ' | xargs svn add

    PS: obviously I'm in a Linux environment. :)

    Friday, May 20, 2011

    Script for importing features into any WSO2 Carbon Feature 3.2.0 (Beta)

    This is small script that works for importing additional features into an existing feature for WSO2 Carbon 3.2.0. For example, for the BAM (Business Activity Monitor) Data publisher feature I wanted to additionally import the Event UI feature as well. Here's a small script that I ran to make this simple.

    Script:

    grep "artifactId>.*ui.feature" -Rl . 
    |grep -v ".svn" | xargs sed -i -e '
    s//\
    \t\t\t\torg.wso2.carbon.event.ui:\${wso2carbon.version}\
    <\/importFeatureDef>\
    /g' 
     
    This has been tested for Carbon 3.2.0, but it should work for Carbon 3.1.0 as well.

    Sunday, May 15, 2011

    Script for making a webapp of Carbon 3.2.0 (Beta)

    I'm not a script junkie, but I thought I'd spend a bit of time and learn a bit, so that I can do something useful with scripts, i.e. go beyond just executing one or two commands with the script.

    So here's a script I wrote to create a webapp out of a WSO2 BAM product. You have to pass in your extracted distribution location tot he script. Ex: sh makeWar.sh ~/wso2/wso2bam-1.3.0-SNAPSHOT.

    After running the script, make sure to follow this cool article, on how to configure and deploy it on weblogic (http://wso2.org/library/knowledge-base/2011/01/deploy-wso2-greg-360-weblogic-103). Now you can skip ahead and start from step 4 - editing the registry.xml part. The steps are more or less the same for other web apps.


    Here's the script: 

    #!/bin/bash curr_dir=${PWD} bam_dir=${PWD}/$1 echo $bam_dir if [ ! -d "$bam_dir" ]; then echo "distro not found" exit fi webapp_parent=wso2-webapp-resources if [ -d "$webapp_parent" ]; then echo "deleting $webapp_parent" rm -rf $webapp_parent fi mkdir $webapp_parent #if [ -f "$curr_dir/wso2bam.war" ]; then # echo "deleting old war" webapp_dir=${webapp_parent}/wso2bam_war echo "Creating WAR" mkdir $webapp_dir cp $bam_dir/lib/core/WEB-INF $webapp_dir -r cp $bam_dir/lib/api/* $webapp_dir/WEB-INF/lib cp `find $bam_dir/lib/ -iname "*.properties"` $webapp_dir/WEB-INF/classes cd $webapp_dir webapp_name=wso2bam.war zip -r $webapp_name . mv $webapp_name $curr_dir cd $curr_dir rm -rf $webapp_dir mv $webapp_name $webapp_parent echo "War created" cp $bam_dir/repository $webapp_parent/ -r echo "repository copied" sed -i -e "s/\/<\/WebContextRoot>/\/wso2bam<\/WebContextRoot>/g" $webapp_parent/repository/conf/carbon.xml sed -i -e "s/https:\/\/\${carbon.local.ip}:\${carbon.management.port}\${carbon.context}\/services\/<\/ServerURL>/https:\/\/localhost:9444\/wso2bam\/services\/<\/ServerURL>/g" $webapp_parent/repository/conf/carbon.xml echo "web context root and server URL changed" grep -Rl "9763" $webapp_parent/repository/ | xargs sed -i -e "s/9763/7001/g" grep -Rl "9443" $webapp_parent/repository/ | xargs sed -i -e "s/9443/7002/g" echo "carbon.xml edited; Please edit registry.xml, user-mgt.xml"