Re: ** Windows 10 Examples **
Bob Friesenhahn <[email protected]> Tue, 23 Mar 2021 11:22:42 -0500 (CDT)
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 23 Mar 2021, Robby Bankston wrote: > > I was looking for some assistance with dynamic output filenames based on > image properties under Windows 10 but haven't been having any luck. > Ultimately I would like to use this for some batch or Powershell scripting > where the input name isn't known and is passed in. The few examples I've > found have been bash style syntax which haven't worked and ImageMagick > syntax didn't work either. I've dug through several tutorials, the docs, > etc. > but I'm either overlooking something or overcomplicating it unnecessarily. > I don't want to have to use 'identify' as a separate operation if possible > as that seems inefficient and my operations are limited to convert and not > mogrify. > > FAILED ATTEMPTS: > gm.exe convert sample.png %t_%wx%h.jpg > gm.exe convert sample.png '%t_%wx%h.jpg' > gm.exe convert sample.png "%t_%wx%h.jpg" > > I know the vast majority of users will probably be in a *nix environment so > Windows users are the minority here but I would really appreciate some > Windows examples added to the documentation to illustrate this. > > Any tips on how to handle this would be much appreciated. > Thank you. While 'gm convert' does support -format as supported by identify, it currently only expands it when the output is to the 'info' coder, and it does not support dynamic output filename generation (which sounds interesting but there may be some security concerns since the file itself might produce some dangerous content). For example, by using the -write option, it works to write some information into the file 'meta.txt': gm convert logo: -format "%m %wx%h" -write info:meta.txt logo.png type meta.txt GIF 654x418 This provides the possibility for your script to use data written to a separate file and rename the file written by GraphicsMagick to the final desired file name based on the contents of that separate file (which might even be the final desired file name). The input file is then only read once, but the script needs to handle the final re-naming itself. Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt