To crop these PNG files, I’m looking for a series of three commands that crops each side of the image according to certain rules (detailed below) and writes the image to the existing PNG file (or to a new PNG file with the same name, if that’s easier). Aside from the cropping, everything else in the file should be preserved (e.g. alpha layer).
The commands would need to work in batch across a a large number of files, and we’d be running them from the Windows command line. (They don’t need to use a particular version of ImageMagick or hook into any other platforms.)
I’d pay $50 for these commands.
Thanks!
Greg
=
The cropping rules:
1. Bottom Crop. Given a list of PNG files (not necessarily of the same height), crop the same amount off the bottom of each image where that amount is the minimum margin between the bottom of the object and the bottom of the image across all the files.
In algorithm form:
- Determine the maximum amount that could be cropped off the bottom of each image (without cropping the object at all), and take the minimum of those maximums. Let’s call this max_crop.
- Crop max_crop off the bottom of each of the PNG files.
- If sample01.png has a distance of 15 px between the bottom of the object and the bottom of the image and sample02.png has a distance of 25 px between the bottom of the object and the bottom of the image, you’d crop 15 px off the bottom of both sample01.png and sample02.png.
In algorithm form:
- For each image, determine the maximum amount that could be cropped off the top (without cropping the object at all).
- Crop that amount off the top of that image.
- If sample01.png has a distance of 15 px between the top of the object and the top of the image and sample02.png has a distance of 25 px between the top of the object and the top of the image, you’d crop 15 px off the top of sample01.png and 25 px off the top of sample02.png.
In algorithm form:
- Determine the maximum amount that could be cropped off the left side of each image (without cropping the object at all), and take the minimum of those maximums. Let’s call this left_max_crop.
- Determine the maximum amount that could be cropped off the right side of each image (without cropping the object at all), and take the minimum of those maximums. Let’s call this right_max_crop.
- Take the minimum of left_max_crop and right_max_crop. Let’s call this max_crop.
- Crop max_crop off the left and right side of each of the PNG files.
- If sample01.png has an object that terminates 15 px from the left side of the image and 20 px from the right side, and sample02.png has an object that terminates 25 px from the left side of the image and 10 px from the right side, you’d crop 10 px off both the right and left sides of both sample01.png and sample02.png.