Page 1 of 1

Batch creating always new file

Posted: 2013-04-20T14:44:22-07:00
by mrkva
I am running simple png to pdf conversion. PNG is change dynamically from my software, and I would like imagemagick to somehow always create a new file when I call it - not overwrite the last one.

Example:
first conversion:
print.png -> conversion -> print.pdf
next conversion:
print.png -> conversion -> print1.pdf

and so on. is it possible? thank you!

Re: Batch creating always new file

Posted: 2013-04-20T15:03:05-07:00
by snibgo
IM doesn't remember anything from one invocation to the next. You could do this in a script, with a counter (perhaps stored in a file) that is incremented each time.

Re: Batch creating always new file

Posted: 2013-04-21T19:50:35-07:00
by anthony
The only time IM will remove an image, is using the special input coder ephemeral:
http://www.imagemagick.org/Usage/files/#ephemeral
When an image is read using that codec, it is then removed from disk.
It is typically used to inform launching programs that it has the image, and is continuing.

WARNING: PHP is often run from the web which means it often will have multiple users running multiple invocations. Ephemeral: is NOT atomic. in that two or more processes could start read a single source image, before that source image is removed by the first process finishes reading.
What happens depends on the OS... DOS would prevent the removal (multi-open) succeeding, while UNIX systems (MacOS/Linux) would remove it, but other programs that have opened it will still see the removed image until the last is finished reading., at which point the file is cleaned up.