Read command options from a file
Read command options from a file
Hi everybody,
I'm trying to use the convert command with many arguments. In fact I want to compose an image with dozens of other pictures.
With windows the command line size is bounded, 2'047 or 8'191 chars.
I don't want that sometime my script generates a command with more than 8'191 and the program fails.
Is there an option to take the command options from a file instead of the regular manner ?
I couldn't find it on the documentation.
I found something about conjure and MSL, but I don't really want to bother with XML right now.
Any ideas ?
Thanks
I'm trying to use the convert command with many arguments. In fact I want to compose an image with dozens of other pictures.
With windows the command line size is bounded, 2'047 or 8'191 chars.
I don't want that sometime my script generates a command with more than 8'191 and the program fails.
Is there an option to take the command options from a file instead of the regular manner ?
I couldn't find it on the documentation.
I found something about conjure and MSL, but I don't really want to bother with XML right now.
Any ideas ?
Thanks
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Read command options from a file
Reading options from a file is a proposal for Im v7 but it requires some changed in option handling.
At this time IM parses options twice, though technically it could do it in a single pass, and thus allow reading of options from a file.
Other things however also need to be resolved too for IM v7 , such as more global use of in-line percent escapes.
At this time IM parses options twice, though technically it could do it in a single pass, and thus allow reading of options from a file.
Other things however also need to be resolved too for IM v7 , such as more global use of in-line percent escapes.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Read command options from a file
Ok thanks,
I'll have to find another ways to compose my image then
I'll have to find another ways to compose my image then
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Read command options from a file
Temporary files. MPC: image files is very fast for reading images back into memory (zero parsing time, disk file just gets mounted as memory)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Read command options from a file
So you suggest something like
?
Code: Select all
convert img.jpg \
balloon.gif -geometry +5+10 -composite \
medical.gif -geometry +35+30 -composite \
present.gif -geometry +62+50 -composite \
shading.gif -geometry +10+55 -composite \
[...]
temp.mpc
convert temp.mpc \
balloon.gif -geometry +5+10 -composite \
medical.gif -geometry +35+30 -composite \
present.gif -geometry +62+50 -composite \
shading.gif -geometry +10+55 -composite \
[...]
final.png
rm temp.mpc
-
- Posts: 59
- Joined: 2009-01-30T03:46:08-07:00
Re: Read command options from a file
depending on just how long your command is and how long it might be, could you possibly get by by just renaming the files to 1, 2, 3, 4, 5, 6, 7, 8, etc..? You wouldn't even need the extension as imagemagick should be able to know what it is by reading the file.
That could save a lot of characters. Renaming is a fast operation. If you needed to preserve the filenames, just remember what they names were before and then rename them back afterwards...
That could save a lot of characters. Renaming is a fast operation. If you needed to preserve the filenames, just remember what they names were before and then rename them back afterwards...
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Read command options from a file
Exactally.
however MPC files are saved as TWO files. The large memory mapped file and a small information file. (.mpc and .cache files). Both needs to be cleaned up.
the advantage of MPC is that it does not need any parseing when read in. It is simply written from and read directly into data memory, AS IS. Under unix it can even use 'memory map' the disk file directly into memory, so IM itself does not need to read the file!
See http://www.imagemagick.org/Usage/files/#mpc
WARNING: MPC files are only good for temporary files. They only work for the particular version of IM that wrote it. They are not for long term storage, which is why they are not commonly used.
however MPC files are saved as TWO files. The large memory mapped file and a small information file. (.mpc and .cache files). Both needs to be cleaned up.
the advantage of MPC is that it does not need any parseing when read in. It is simply written from and read directly into data memory, AS IS. Under unix it can even use 'memory map' the disk file directly into memory, so IM itself does not need to read the file!
See http://www.imagemagick.org/Usage/files/#mpc
WARNING: MPC files are only good for temporary files. They only work for the particular version of IM that wrote it. They are not for long term storage, which is why they are not commonly used.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Read command options from a file
Hi .. any news on that topic ?
I found:
"Some ImageMagick command-line options may exceed the capabilities of your command-line processor. Windows, for example, limits command-lines to 8192 characters. If, for example, you have a draw option with polygon points that exceed the command-line length limit, put the draw option instead in a file and reference the file with the @ (e.g. @mypoly.txt)." Examples for that avaliable ?
I.e I want to create a layered image with explicit positional data:
layers.dat
-page +0+0 m1@1.bmp
-page +150+44 m1@2.bmp
-page +300+87 m1@3.bmp
convert @layers.dat -background rgb(10,10,200) -layers merge +repage overview.bmp
provides an error : UnableToOpenBlob
whereas the full command work sfine:
convert -page +0+0 m1@1.bmp -page +150+10 m1@2.bmp -page +300+20 m1@3.bmp -background rgb(10,10,200) -layers merge +repage overview.bmp
Unfortunatelly I don't have simply 3 images I have hundrets of them (with full path) so the windows command line length exceeds.1
The layers.dat could be calculated and written per another script during image acquisition ... (of a microscopic XY-stage).
Many thanks,
CHris
I found:
"Some ImageMagick command-line options may exceed the capabilities of your command-line processor. Windows, for example, limits command-lines to 8192 characters. If, for example, you have a draw option with polygon points that exceed the command-line length limit, put the draw option instead in a file and reference the file with the @ (e.g. @mypoly.txt)." Examples for that avaliable ?
I.e I want to create a layered image with explicit positional data:
layers.dat
-page +0+0 m1@1.bmp
-page +150+44 m1@2.bmp
-page +300+87 m1@3.bmp
convert @layers.dat -background rgb(10,10,200) -layers merge +repage overview.bmp
provides an error : UnableToOpenBlob
whereas the full command work sfine:
convert -page +0+0 m1@1.bmp -page +150+10 m1@2.bmp -page +300+20 m1@3.bmp -background rgb(10,10,200) -layers merge +repage overview.bmp
Unfortunatelly I don't have simply 3 images I have hundrets of them (with full path) so the windows command line length exceeds.1
The layers.dat could be calculated and written per another script during image acquisition ... (of a microscopic XY-stage).
Many thanks,
CHris
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Read command options from a file
Well, both v6 and v7 have script facilities. Annoyingly, they are different. (For example: v6 scripts return back to the command line, but v7 scripts don't.) What version of IM are you using?Spammy63 wrote:Hi .. any news on that topic ?
You "layers.dat", with three lines, works fine for me, under v6.9.5-3. (The developers say it wasn't designed to work under v6, so it doesn't under v7. The replacement under v7 is "-script", which works differently.)
snibgo's IM pages: im.snibgo.com
Re: Read command options from a file
Such a quick answer, thanks !
I use v6.9.5.3 - under windows10 - after fiddling around ist works - BUT IGNORES THE FIRST ENTRY in layers.dat - this first entry provides an error messages but the rest of the entires is processed without problems ! The following modification of layers.dat provides an error message (UnableToOpenBlob) but works so far for what I need it. Will do further tests with huge amount of image entries in layers.dat.
modified layers.dat (first line doubled:)
-page +0+0 m1@1.bmp
-page +0+0 m1@1.bmp
-page +128+0 m1@2.bmp
-page +256+0 m1@3.bmp
-page +0+96 m2@1.bmp
-page +128+96 m2@2.bmp
-page +256+96 m2@3.bmp
Strange ...
Chris
I use v6.9.5.3 - under windows10 - after fiddling around ist works - BUT IGNORES THE FIRST ENTRY in layers.dat - this first entry provides an error messages but the rest of the entires is processed without problems ! The following modification of layers.dat provides an error message (UnableToOpenBlob) but works so far for what I need it. Will do further tests with huge amount of image entries in layers.dat.
modified layers.dat (first line doubled:)
-page +0+0 m1@1.bmp
-page +0+0 m1@1.bmp
-page +128+0 m1@2.bmp
-page +256+0 m1@3.bmp
-page +0+96 m2@1.bmp
-page +128+96 m2@2.bmp
-page +256+96 m2@3.bmp
Strange ...
Chris
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Read command options from a file
On Windows 8.1, I don't get UnableToOpenBlob, and I don't need to double the first line. Is your layers.dat a text file, just plain ASCII text with no UTF or anything else?
snibgo's IM pages: im.snibgo.com
Re: Read command options from a file
... have to test. maybe there is a problem.
Re: Read command options from a file
plain ascii .. behaviour as described.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Read command options from a file
Oh dear, I was running an old version of IM. Under v6.9.5-3, "@" scripts seem to be broken. I also get an error message and the first line is ignored, then following lines work.
As I've mentioned, scripts with image options were never supposed to work under v6, so the developers may say, "tough luck".
As I've mentioned, scripts with image options were never supposed to work under v6, so the developers may say, "tough luck".
snibgo's IM pages: im.snibgo.com