Cropping a CR2 file using the XMP profile

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?".
Post Reply
aporthog
Posts: 37
Joined: 2012-05-30T08:24:46-07:00
Authentication code: 13

Cropping a CR2 file using the XMP profile

Post by aporthog »

I was all set to write a custom cropping script using the crs:Crop settings in the XML profile by calculating those values as percentages of the original image dimensions. Then I noticed IM can read the profile using the -profile switch with an xmp: prefix on the profile filename. I tried running the command "convert abc005_L.CR2 -profile xmp:abc005_L.xmp abc005_L.tif" but the resulting tiff was uncropped. So is there a way for IM to automatically create a cropped version of a cr2 file on the command line (like I see when I open the cr2 in Photoshop) or will I have to go ahead and calculate the geometries and use them with a -crop switch as was my original plan?

crs:CropTop="0.342177"
crs:CropLeft="0.245271"
crs:CropBottom="0.830426"
crs:CropRight="0.776552"
crs:CropAngle="-0.450656"
crs:CropConstrainToWarp="1"
crs:HasCrop="True"

Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cropping a CR2 file using the XMP profile

Post by anthony »

Not automatically. In IMv7 you may be about to directly crop using the profile values, but in IMv6 you will need to use a script to first extract those values, and then call IM to do the crop. You may want to remove those profilvalues after cropping, though IM may not be able to do this. At least not at this time.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
aporthog
Posts: 37
Joined: 2012-05-30T08:24:46-07:00
Authentication code: 13

Re: Cropping a CR2 file using the XMP profile

Post by aporthog »

Thanks. I'm using IM6. I went ahead and wrote a script which was pretty easy after all. Good point about removing the profile values after cropping.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cropping a CR2 file using the XMP profile

Post by anthony »

Be sure to use +repage after the crop to remove any old virtual canvas (page) information, so that it matches the new newly cropped image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
prohtex
Posts: 4
Joined: 2016-12-20T11:45:27-07:00
Authentication code: 1151

Re: Cropping a CR2 file using the XMP profile

Post by prohtex »

Hi aporthog, any chance you might be willing to share this script or the logic you used to convert the XMP crop values to IM crop area? Thanks!
Post Reply