Wednesday, 6 May 2015

Turning on Sony Bravia TV from a computer terminal

Sony Bravia TV allows one to wake it up using (WoL) Wake On LAN. Look for settings on your respective models.

$ sudo apt install wakeonlan 

wakeonlan is a script/utility which allows sending magic packets to networked devices which allow WoL.

The IP address can be found from modem admin utility which also shows the mac address for the TV.

Following command will turn the TV on.

$ wakeonlan -i "IP address of the TV" "Mac address of the TV"


Thursday, 11 September 2014

Recovering photos from iPOD. (convert ITHMB files to *.png)

Used the following method to recover photos stuck in first generation ipod.

Had lost the originals but found the photos safe in the ipod. iPod converts the originals to small size and stores. Apple does not support this. Asked in 2 different stores.

So had to rely on online help. imageMagick utility converts the photos from uyvy format to png. The only thing required is to get individual photos from the big ITHMB files. The following JAVA code did that.

The ITHMB file name and image sizes are as below:

 1019_*.ithmb offset: 7603200, imgsize: 691200 
 1020_*.ithmb offset: 851840, imgsize: 77440
 1009_*.ithmb offset: 27720, imgsize: 2520
 1015_*.ithmb offset: 251680, imgsize: 22880

We use the 1019_*.ithmb file as its meant for TV output. (720x480 interlaced UYVY (YUV 4:2:2) - used for TV output - 691200 bytes each single thumbnail)

Read details here.
Step 1: The following program will read the ITHMB file and separate out the photos into *.uyvy format.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

public class ReadITHMBfile {

static int count = 1,fileCount = 1;
static byte[] intFis = new byte[1];
static BufferedInputStream fis = null;
static BufferedOutputStream fos = null;
static String ithmbExt = ".ithmb", pngExt = ".png";
static Path startingDir;
static private final PathMatcher matcher = null;

public static void main(String[] args)   // unit testing
{
/*if (args[0].length() == 0 )
{
throw new IllegalArgumentException("Pass Directory containing .ITHMB files as Argument");
}

startingDir = Paths.get(args[0]);


matcher = FileSystems.getDefault().getPathMatcher(startingDir+ITHMBFileName);
        Files.walkFileTree(startingDir, matcher);
        finder.done();*/
String ITHMBFileName = "F1019_2";

File fInput  = new File("/home/raj/Pictures/"+ ITHMBFileName + ithmbExt);
File fOutput = new File ("/home/raj/Pictures/FromiPOD/"+ ITHMBFileName +"_"+ fileCount + ".uyvy");

try { 

fis = new BufferedInputStream(new FileInputStream(fInput),2048);
fos = new BufferedOutputStream(new FileOutputStream(fOutput));

while ( fis.read(intFis) >= 0)

{
if (count <= (720 * 480 * 2))
{
//StdOut.print(new Character((char)(intFis[0])) + " in Ascii ");
//StdOut.print(intFis[0] + " in Hex ");
//StdOut.println(new Integer(intFis[0]).toHexString(intFis[0]));
fos.write(intFis);
count=count+1;
}
else
{
fos.close();
fileCount++;
fOutput = new File ("/home/raj/Pictures/FromiPOD/"+ ITHMBFileName +"_"+ fileCount + ".uyvy");
fos = new BufferedOutputStream(new FileOutputStream(fOutput));
fos.write(intFis);
count = 2;
}
}
}
catch (IOException e) 

e.printStackTrace(); 
System.err.println("Error generating uyvy file"); 
}

finally {

try {
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}

}

}

}



Step 2: Download and install the imageMagick utility.
Step 3: Create a mask.png file using the following command. (convert is an imageMagick utility)
convert xc:black xc:white -append -write mpr:m +delete -size 720x400 tile:mpr:m mask.png

Step 4: Using the mask now convert each *.uyvy file to *.png file.
On Linux
for i in {1..759};
 do
 convert -size 720x480 -depth 16 -sampling-factor 4:2:2 F1019_2_$i.uyvy -crop 100%x50% -filter Point -resize 100%x200% mask.png -composite F1019_2_$i.png
done


Tuesday, 22 February 2011

Eclipse change required after Ubuntu upgraded the JRE

Did yet another update for Ubuntu 10.04. It installed JRE 1.6 when earlier had JRE 1.5

As a result Eclipse could not find the required JRE system library. As a result the project gave compilation errors "import java.util.*" cannot be resolved etc.

Eclipse picks up these libraries from the installed JREs. This can be changed from the Project (right click)--> Properties --> Libraries .

So removed the flagged library and added the JRE system library from the installed JRE.

Monday, 31 January 2011

State of internet 2010

Windows7 theme wallpapers on Ubuntu.

1. Windows 7 compresses its themes in a compression other than .zip/.rar etc. Windows 7 themes can be downloaded from

2. Download the theme. The filename will be *.themepack

3. Install 7zip - Go to Ubuntu Software centre >> Accessories >> look for 7zip and install.

4. 7zip can be invoked using 7za/7z.

5. $7za e
will unzip the themepack in the folder specified.

6. Use to have windows7 theme wallpapers on ubuntu.

Sunday, 5 December 2010

Javascript to make a REST api call

Javascript to make a REST api call.

//*


JSON/Atom Custom Search API Example