Batch creating always new file

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
mrkva
Posts: 1
Joined: 2013-04-20T14:42:16-07:00
Authentication code: 6789

Batch creating always new file

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Batch creating always new file

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Batch creating always new file

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply