Convert execution keeps on running.

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
thdbased
Posts: 8
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Convert execution keeps on running.

Post by thdbased » 2019-11-12T09:21:49-07:00

Hello,

I have a strange issue with a command I'm executing using external process I'm starting from .net code:

convert "image.png" -roll +1+1 -alpha remove -crop 2x2+0+0 +repage txt:

This works for 99% of the images coming in, but in small cases there are images coming in which will execute this command for hours. That's not that big of a problem, but I would like to have a way to limit execution time of this, since setting a timeout from .net has no effect, also cmd line params or policy attributes have no effect, it just keeps running.

Any ideas? Many thanks.

snibgo
Posts: 12416
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert execution keeps on running.

Post by snibgo » 2019-11-12T11:04:54-07:00

What version of IM? Recent versions have a timeout option in policy.xml.

Please link to a problem input png so it can be tested.
snibgo's IM pages: im.snibgo.com

thdbased
Posts: 8
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Re: Convert execution keeps on running.

Post by thdbased » 2019-11-13T01:48:01-07:00

Thx for the help :)

ImageMagick 7.0.5-10 locally, but we also have it on an other environment running 7.0.8.5 we have the same.
Also tried using a timeout value in policy.xml: <policy domain="resource" name="time" value="10"/> , but doesn't have any effect.

Test file: https://drive.google.com/open?id=1BUUaQ ... uRyKhnJyI-

snibgo
Posts: 12416
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert execution keeps on running.

Post by snibgo » 2019-11-13T05:45:42-07:00

Code: Select all

f:\web\im>%IMG7%magick id_bad.png info:

id_bad.png PNG 1680x1680 4312560x4347840-1680-1680 8-bit Gray 8728B 0.469u 0:00.173
Notice the very large virtual canvas. I suggest you insert "+repage" after reading the input file.

You might also investigate where the the input file came from, and fix whatever causes the very large virtual canvas.
snibgo's IM pages: im.snibgo.com

thdbased
Posts: 8
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Re: Convert execution keeps on running.

Post by thdbased » 2019-11-13T07:07:15-07:00

Hi thx, also suspected this was coming from the large canvas.

For a potential fix you mean, You mean something like this?

convert "image.png" +repage -roll +1+1 -alpha remove -crop 2x2+0+0 +repage txt:

snibgo
Posts: 12416
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert execution keeps on running.

Post by snibgo » 2019-11-13T07:37:06-07:00

Yes, that's it.
snibgo's IM pages: im.snibgo.com

thdbased
Posts: 8
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Re: Convert execution keeps on running.

Post by thdbased » 2019-11-13T07:52:59-07:00

Works indeed thx. Won't this have any bad influence on the output? Since I read it removes basically the canvas information.

snibgo
Posts: 12416
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert execution keeps on running.

Post by snibgo » 2019-11-13T08:11:14-07:00

Yes, "+repage" removes the canvas metadata. So does your "+repage" after the crop. Is the original canvas metadata meaningful after doing the roll and crop? If it is, you could save that metadata, perhaps calculate what the WxH+X+Y values should be, and restore those with "-page".
snibgo's IM pages: im.snibgo.com

thdbased
Posts: 8
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Re: Convert execution keeps on running.

Post by thdbased » 2019-11-14T02:35:49-07:00

Thx a lot for the help! The only strange thing we still see is we are not able to timeout the call properly (like all of our other calls). If it would take way too long due to the canvas we would like to have it stop instead of going in a almost hanging state.

Post Reply