Running the crop and repage commands result in different input if the image file is a MPC or PNG derived from the MPC.
Version: ImageMagick 6.9.1-Q16
Operating System: Windows 7 x64
Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40 GHz
Installed memory (RAM): 8.00 GB
Command line:
Given the MPC and Cache files available at OneDrive: http://1drv.ms/1DATSjd
1. convert "iCopy 2015-07-23 11-16 000_1.mpc" -virtual-pixel edge -blur 0x15 -fuzz 10% -trim -format "%wx%h%O" info:
2. You will see "1875x3484+1350+567"
3. convert "iCopy 2015-07-23 11-16 000_1.mpc" "iCopy 2015-07-23 11-16 000_1.png"
4. convert "iCopy 2015-07-23 11-16 000_1.png" -virtual-pixel edge -blur 0x15 -fuzz 10% -trim -format "%wx%h%O" info:
5. You will see "1875x3484+1350+567" again
6. Run the following commands to crop the images and get rid of the gray
convert "iCopy 2015-07-23 11-16 000_1.mpc" -monitor -crop "1875x3484+1350+567" +repage "bad.png"
convert "iCopy 2015-07-23 11-16 000_1.png" -monitor -crop "1875x3484+1350+567" +repage "good.png"
7. Notice that bad.png shows a tiny sliver of the receipt whereas good.png shows the entire receipt.
Crop and Repage with MPC Behaves Differently Than With PNG
-
snibgo
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
- Contact:
Re: Crop and Repage with MPC Behaves Differently Than With PNG
The input MPC contains an offset of -5-1, which you probably don't want. "+repage" will get rid of it. But that's not the real problem.
The real problem is that the input MPC contains a gravity setting. This isn't copied to the PNG because PNG can't contain gravity metadata. Override this with an explicit gravity in your final command:
(I've also added it to the PNG command, where it is superfluous but harmless.)
The real problem is that the input MPC contains a gravity setting. This isn't copied to the PNG because PNG can't contain gravity metadata. Override this with an explicit gravity in your final command:
Code: Select all
convert "iCopy 2015-07-23 11-16 000_1.mpc" -gravity NorthWest -crop "1875x3484+1350+567" +repage "better.png"
convert "iCopy 2015-07-23 11-16 000_1.png" -gravity NorthWest -crop "1875x3484+1350+567" +repage "good.png"snibgo's IM pages: im.snibgo.com
Re: Crop and Repage with MPC Behaves Differently Than With PNG
I adapted your suggestions to reset the coordinate system and explicitly set the gravity. The changes fixed the problem.
Thank you for the help.
Thank you for the help.
Who is online
Users browsing this forum: No registered users and 9 guests