How to trim a large image?

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
etrader
Posts: 17
Joined: 2012-09-29T06:53:04-07:00
Authentication code: 67789

How to trim a large image?

Post by etrader »

In a script, I trim supplied images with

Code: Select all

convert source.png -trim target.jpg
everything works perfectly, but when a large picture with a large white area (e.g., 20,000px height with 80% white), the command freezes (32 cores work for hours but not output).

I have no control over the supply of such anomalous pictures. How can I make the command work or skip when it is not workable?

I use ImageMagick 7.0.8-34 Q16 x86_64 on Ubuntu.

User avatar
fmw42
Posts: 26272
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to trim a large image?

Post by fmw42 »

It sounds like you may either be running out of RAM or not have enough room in /tmp. Check /tmp and delete any images that contain Imagemagick in the name and any other large images. Also see the Imagemagick policy.xml file about setting resources and perhaps moving your TEMP directory to some other one that has plenty of space. Also check your resources with

Code: Select all

convert -list resource
convert -list policy

Post Reply