Convert ithmb

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Convert ithmb

Post by smclellan »

First of all - to whom it may concern - thank you for such a powerful and simple tool. It is a lifesaver.
Secondly, I am having an issue converting .ithmb files to a usable image format. I have had some success by renaming the .ithmb to .uyvy format and then converting to a .png and/or .jpg. However, when I convert, I end up with two identical images stacked on top of one another in the size specified - the overall height is what I specified so essentially I get two half-height images on top of each other.
BACKGROUND
I began by using Keith's iPod Photo Reader (http://keithwiley.com/software/keithsIP ... ader.shtml) and can export the files from there in a proper way (there are a lot of files and this tool only allows converting one at a time so it is practically useless for my purposes). This tool was very useful in determining some of the information about the files though. Using it, I was able to determine that they are 720x480 16-bit YCbCr 4:2:2 with Interlaced Shared Chrominance. This tool has an option to "Flip Endian" and only when that option is enabled does the exported image file display properly.
Using ImageMagick command line on a Mac, I run the command

Code: Select all

convert -size 720x480 -depth 16 -sampling-factor 4:2:2 FileName.uyvy FileName.png
The resulting image file is as described above - two half-height images stacked on top of each other with a total height of 480.
MY TROUBLESHOOTING
I have tried each option for the -endian option (LSB and MSB) with no difference in output image file. I have tried -interlace option (None, Line, Plane and Partition) with no difference in output image file.

THE QUESTION
Can the endianness of the image be flipped?
smclellan

Posts: 1
Joined: 2013-10-16T16:29:11+00:00
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert ithmb

Post by fmw42 »

smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

fmw42,
From what I can see, as in my post, there are only two options for the -endian option, LSB and MSB. I have tried both of those, but, full disclosure, I have no idea what endianness is or how it affects an image. Are there more options for -endian that I am not aware of. -list endian only displays those two options as well.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert ithmb

Post by snibgo »

If the two halves are identical, then one half is redundant. You could crop and resize.

If you provide a .uyvy file, someone might experiment.
snibgo's IM pages: im.snibgo.com
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

Snibgo, I am not 100% sure that both halves are identical, but the link provided is one of the .uyvy files for experimentation. https://www.dropbox.com/s/fh172mbkv8m7ls5/T1016.uyvy
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

snibgo, here is a link to the resulting file I get when converting from the uyvy to jpg (same result as with png). https://www.dropbox.com/s/8ve2dumgzl8eunr/T1016.jpg
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert ithmb

Post by snibgo »

Converting your image, chopping in half and magnifying greatly suggests the halves are similar but displaced vertically by half a pixel. This suggests the two halves should be interleaved. There may be a neater way of combining the two halves, but here is one. Windows script:

Code: Select all

convert ^
  -size 720x480 -depth 16 -sampling-factor 4:2:2 ^
  t1016.uyvy ^
  ( +clone -crop 720x240+0+0 -write t0.png +delete ) ^
  ( +clone -crop 720x240+0+240 -write t1.png +delete ) ^
  NULL:

convert ^
  xc:black xc:white -append -write mpr:m +delete ^
  -size 720x400 ^
  tile:mpr:m ^
  mask.png

convert ^
  -filter Point ^
  t0.png t1.png ^
  -resize 100%%x200%% ^
  mask.png ^
  -composite ^
  t.png
With large magnification, the bottom quarter or so of the result is strangely blocky (2x2 pixels). This may be an artifact of the original compression.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert ithmb

Post by fmw42 »

Is the OP on Unix or Window. If snibgo is correct, I have a script, interleave, at the link below that might help to do that on Unix.
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

fmw42 and snibgo, I am running Mac OS Mountain Lion so Unix is my OS.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert ithmb

Post by fmw42 »

smclellan wrote:fmw42 and snibgo, I am running Mac OS Mountain Lion so Unix is my OS.
What version of IM?

Please review viewtopic.php?f=1&t=9620 if you have not already.

This question is probably out of my expertise. I do not know what a uyvy format image is and do not know if IM supports that format?

So I will leave this up to snibgo, who seems to have a better handle on it.
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

fmw42, I am not really sure what the uyvy format is either. I am assuming that it is some type of RAW format. Is there a command I can run to determine the IM version? It is the most recent version that installs with MacPorts. I installed it today.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert ithmb

Post by fmw42 »

smclellan wrote:fmw42, I am not really sure what the uyvy format is either. I am assuming that it is some type of RAW format. Is there a command I can run to determine the IM version? It is the most recent version that installs with MacPorts. I installed it today.
It looks like subsampling variant of YUV as per http://www.fourcc.org/yuv.php and apparently packed as two pixels at a time.

It may be some form of raw image, but I do not know how IM would interpret it without one using some delegate and providing the arguments, unless there is some header information. Snibgo likely understands this better and it appears from his command that it is a raw format and he has given the correct sampling-factor. But perhaps this format requires interleave arguments as well, for which I do not know that IM has provisions. One would have to study the file format more carefully perhaps from the reference above.

You can find the IM version using the command

convert -version

But if you installed the latest from MacPorts, then it is likely only a few release older than the current IM version.
smclellan
Posts: 11
Joined: 2013-10-16T14:29:11-07:00
Authentication code: 6789

Re: Convert ithmb

Post by smclellan »

This is the output of convert -version

Version: ImageMagick 6.8.7-0 2013-10-16 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib djvu fftw fontconfig freetype gslib jng jpeg lcms ltdl lzma png ps png tiff webp x xml zlib


IM seems to recognize the uyvy format in some fashion at least since it does convert from uyvy to png(I am assuming this, but as you know, I am very new to IM and Forums for that matter). For all I know I could convert a docx to png.
Last edited by smclellan on 2013-10-16T17:59:50-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert ithmb

Post by fmw42 »

Actually IM does have a setting, for interlace of raw images, but I am not sure that is what you need. But you can try that. See http://www.imagemagick.org/script/comma ... #interlace

Yes, you are using the most current release.

Good reading is at:
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
Last edited by fmw42 on 2013-10-16T18:01:20-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert ithmb

Post by snibgo »

My script can be tidied up slightly:

Code: Select all

convert ^
  xc:black xc:white -append -write mpr:m +delete ^
  -size 720x400 ^
  tile:mpr:m ^
  mask.png

convert ^
  -size 720x480 -depth 16 -sampling-factor 4:2:2 ^
  T1016.uyvy ^
  -crop 100%%x50%% ^
  -filter Point -resize 100%%x200%% ^
  mask.png ^
  -composite ^
  t.png
To convert my Windows script to Unix etc:

1. Change every "^" to "\". In my script, these are only at line ends.

2. Escape parentheses: change "(" to "\(" and ")" to "\)". The revised script has no parentheses.

3. Windows needs to escape "%" but Unix doesn't, so change every "%%" to "%".

I think that's all you need.

I know nothing about uyvy, but smclellan has done all the work, showing how to convert that to anything else.
Last edited by snibgo on 2013-10-16T18:03:46-07:00, edited 1 time in total.
snibgo's IM pages: im.snibgo.com
Post Reply