![]() You could extract the BoundingBox from the EPS with awk like this: bbox=$(awk '/%%BoundingBox:/ ' image.eps)Īnd then use it like this: magick image.eps -gravity southwest -crop "$bbox" result. Or there may be a better approach altogether. I am not sure whether any of these approaches will be reliable for all your images, so you may need to experiment and report back any problematic files. I see also that exiftool reports a bounding box as follows: exiftool image.epsįile Modification Date/Time : 2021:05:04 07:58:44+01:00įile Access Date/Time : 2021:05:04 08:00:11+01:00įile Inode Change Date/Time : 2021:05:04 07:58:44+01:00Īnd that this gives a reasonable result too: magick image.eps -gravity southwest -crop 305x305+0+0 result.jpg So, if for example, you want to crop 150x120 out of the southwest corner, set the gravity and use an offset of +0+0 like this: magick image.eps -gravity southwest -crop 150x120+0+0 result.jpg If you find you need to use -crop for other cases, you most likely have a problem with getting lots of output images because you didn't specify an offset. because of possible fragility leading to all my images being deleted. another file every time we crop the images. If that is trimmed too closely for your liking, you can add a 10 pixel wide border back on to give it room to breathe like this: magick image.eps -trim -bordercolor white -border 10 result.jpg A script for cropping whitespace around images using ImageMagick. Trimming the image (which removes whitespace around the edges) seems to do what you want quite simply in this case: magick image.eps -trim result.jpg What is the trick for retaining the image's bounding box when it converts to PNG? I'm pretty sure that -crop should work but I evidently have not figured out how to correctly specify the crop dimensions. Next, I tried -crop, -resize, and various combinations of those, but this typically gives me a LOT of individual PNG files that display small portions of that overall 612x792 image. ![]() The image winds up in the lower-left corner of a PNG file that is 612x792 pixels, with a ton of white space everywhere else. When I use this command: convert myfile.eps myfile.png I want to convert the image from the command line to PNG with the same image dimension. The image consists of a collection of blue circles. ![]() aspectcrop -a 2:1 test.png Fredwins.png. %!PS-Adobe-3.0 EPSF-3.0ġ60.631 121.588 6.99204 0 360 arc closepath If you would prefer to simply and automatically crop an image to a specified aspect ratio the easiest way is to use one of Freds ImageMagick Scripts: Aspectcrop. Giacomo1968 gave a working solution, but I think a much easier solution is not to script it, but to use two step conversion. Just for the sake of completeness, here are the first few lines of the EPS file- I'm calling it myfile.eps for this example. I have a simple EPS image that I want to convert to PNG. I realize there are similar questions already posted, but none of them seem to address my issue, and I'm not getting anywhere with the man page for Imagemagick's convert. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |