Page 1 of 1
How to extract part of dvd cover image
Posted: 2010-11-08T01:56:30-07:00
by popejobs
I've played with the various crop options but I'm lost. I'm trying to figure out the proper commandline to take a dvd boxcover image "Cover.jpg" and crop it so that i'm left with a new file "Folder.jpg" which has the left side image and spine in the center removed.
Given that the source cover images are of varying WxH dimensions yet nearly always the same aspect ratio, I assume I want to crop by percentage. in this example the Cover.jpg is 303px for the left part of the image plus 34px for the spine, leaving 303px for the right part of the image i want to keep. so 303/640 = 47.343 percent of the right side of the image that i want to keep.
Would someone mind helping me find the best operators to accomplish this? thanks in advance.

Re: How to extract part of dvd cover image
Posted: 2010-11-08T02:31:03-07:00
by GreenKoopa
This sounds like a task easily accomplished using ImageMagick. Check out:
ImageMagick v6 Examples >
Cutting and Bordering >
Crop a Percentage of an Image
ImageMagick: Command-line Options >
-gravity and
-crop
If you still can't get it to work, let me know what you have tried and what didn't happen that you wanted.
Re: How to extract part of dvd cover image
Posted: 2010-11-08T04:01:03-07:00
by popejobs
i'm guessing the first step is getting the image to a fixed width, to not have to deal with percentages. so far i've got:
"convert.exe COVER.JPG -resize 800 -crop 420x0 FOLDER.JPG"
however that spits out two files: folder-0.jpg and folder-1.jpg. the contents of folder-1.jpg is exactly what I need, so how do I change the commandline so it doesn't write a folder-0.jpg?
Re: How to extract part of dvd cover image
Posted: 2010-11-08T04:44:59-07:00
by GreenKoopa
An initial resize to avoid percentages is certainly a valid way to go. Since your
image geometry for the crop (420x0) specifies a size yet not an offset (location) you want, your are chopping your image into pieces (or tiles, of size 420x
0, I guess). Specify an offset to get just one piece.
Here is my stab at a percentage solution:
convert Cover.jpg -gravity east -crop 47%x100% Folder.jpg
You seem to be using Windows, so remember to escape %s in batch files.
Re: How to extract part of dvd cover image
Posted: 2010-11-08T05:00:22-07:00
by GreenKoopa
Or try replacing your -crop with
-chop
Re: How to extract part of dvd cover image
Posted: 2010-11-08T05:33:11-07:00
by popejobs
GreenKoopa wrote:Or try replacing your -crop with
-chop
that did it. much thanks.
Re: How to extract part of dvd cover image
Posted: 2010-11-08T11:17:24-07:00
by fmw42
You don't have to work with percentages, -crop works with pixel coordinates
-crop follows this format
-crop WxH+X+Y +repage
W=width of section you want (after your resize if desired)
H=height of section you want
X=initial start x position (upper left corner of section you want)
Y=initial start y position (upper left corner of section you want)
+repage removes the virtual canvas which stores the crop coordinates
see
http://www.imagemagick.org/Usage/crop/#crop_repage
If you leave off the +X+Y, IM tries to generate all non-overlapping subsections of size WxH
see
http://www.imagemagick.org/Usage/crop/#crop_equal
Note you can also crop relative to a corner or side - see
http://www.imagemagick.org/Usage/crop/#crop_gravity
So in this case, if you know you just want the right side of some WxH, use
convert image -gravity east -crop WxH+0+0 +repage result
or if you want percent (
http://www.imagemagick.org/Usage/crop/#crop_percent), then if the W=47.343%
convert image -gravity east -crop 47.343x100%+0+0 +repage result
But pixels will ensure you get exactly what you want.