How to use imageMagick to convert a ppm image to YUV422

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?".
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: How to use imageMagick to convert a ppm image to YUV422

Post by glennrp »

There's no header so you need -size WxH and because Cb and Cv aren't recognized
as input formats you have to do something like

Code: Select all

mv Bretagne2.Cp temp.gray
convert -size WxH -resize 50% temp.gray ~/Downloads/Bretagne2-ds.Cb
mv Bretagne2.Cv temp.gray
convert -size WxH -resize 50% temp.gray ~/Downloads/Bretagne2-ds.Cv
michaels
Posts: 11
Joined: 2014-01-16T14:47:22-07:00
Authentication code: 6789

Re: How to use imageMagick to convert a ppm image to YUV422

Post by michaels »

Thanks. But I get an 'unexpected end of file error:
The original image Bretagne1.ppm from http://www.openjpeg.org/index.php?menu=samples. is 640X480.

Code: Select all

$ mv Bretagne2.Cb temp.gray
$ convert -size 640x480 -resize 50% temp.gray ~/Downloads/Bretagne2-ds.Cb
convert: unexpected end-of-file `temp.gray':  @ error/gray.c/ReadGRAYImage/205.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: How to use imageMagick to convert a ppm image to YUV422

Post by glennrp »

michaels wrote:Thanks. But I get an 'unexpected end of file error:
The original image Bretagne1.ppm from http://www.openjpeg.org/index.php?menu=samples. is 640X480.

Code: Select all

$ mv Bretagne2.Cb temp.gray
$ convert -size 640x480 -resize 50% temp.gray ~/Downloads/Bretagne2-ds.Cb
convert: unexpected end-of-file `temp.gray':  @ error/gray.c/ReadGRAYImage/205.
You have to account for the downsampling while creating *.Cb and *.Cv; use -size 320x240 to read temp.gray.
Post Reply