How to work with files separately?
How to work with files separately?
Is it possible to take 2 images, make some processing with them, then export them in 2 different variables (do not save to files) and then use these variables as inputs for other ImageMagic commands?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to work with files separately?
What type of variables? What is your script language? What version of IM?
You can write to "txt:" or non-compressed PNM format and save that in a bash variable:
But there is a large overhead in converting to text and back. You should also consider using pipes, probably using IM's built-in "miff" format.
You can write to "txt:" or non-compressed PNM format and save that in a bash variable:
Code: Select all
myimg=$(convert rose: txt:)
snibgo's IM pages: im.snibgo.com
Re: How to work with files separately?
When I said "variables" I didn't mean txt. I meant saving images to some instances inside ImageMagic (save to RAM, not to hdd).
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to work with files separately?
IM can images save to RAM for use later within the same command. But they can't be used in later commands. Memory and commands don't work that way.
You might consider a RAMdisk (eg see https://www.ghacks.net/2017/04/03/the-b ... r-windows/) or SSD.
Piping is a common technique.
You might consider a RAMdisk (eg see https://www.ghacks.net/2017/04/03/the-b ... r-windows/) or SSD.
Piping is a common technique.
snibgo's IM pages: im.snibgo.com
Re: How to work with files separately?
I'm not sure that RAMdisk is the best for this case. Let me ask in another way. Lets say I have 3 input images: 1.jpg, 2.jpg, 3.jpg.
I'd like do increase the first one by 10%, then rotate it 90 degrees clockwise, then save it as out1.jpg.
The second image to reduce by 20%, then overlay it to right bottom corner of out1.jpg and save it to out2.jpg.
The third one combine horizontally with 1.jpg (original) and out2.jpg using +append.
How does ImageMagic line will look like?
I'd like do increase the first one by 10%, then rotate it 90 degrees clockwise, then save it as out1.jpg.
The second image to reduce by 20%, then overlay it to right bottom corner of out1.jpg and save it to out2.jpg.
The third one combine horizontally with 1.jpg (original) and out2.jpg using +append.
How does ImageMagic line will look like?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to work with files separately?
See parenthesis processing and clones. You should be able to do that all in one command.
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/basics/#clone
If I understand your request, try this (unix syntax)
___________________________
Helpful pages:
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/basics/#clone
If I understand your request, try this (unix syntax)
Code: Select all
convert \( 1.jpg -resize 110% -rotate 90 \) \
\( +clone \( 2.jpg -resize 80% \) -gravity southeast -compose over -composite \) \
3.jpg \
+gravity +append \
result.jpg
Helpful pages:
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
Re: How to work with files separately?
fmw42, thank you
Re: How to work with files separately?
How does this " \( " change in windows?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to work with files separately?
See my edits above. For windows, remove the \s with the \( and for the end of line \ change to ^
see https://imagemagick.org/Usage/windows/
see https://imagemagick.org/Usage/windows/
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to work with files separately?
Fred's version doesn't save out1.jpg and out2.jpg. But I'm not sure if you really wanted that.
snibgo's IM pages: im.snibgo.com
Re: How to work with files separately?
Is it possible to do several out files?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to work with files separately?
Insert "+write out1.jpg" or whatever.
snibgo's IM pages: im.snibgo.com
Re: How to work with files separately?
Here in brackets?
What does +write do?
Code: Select all
convert \( 1.jpg -resize 110% -rotate 90 +write out1.jpg \) \
\( +clone \( 2.jpg -resize 80% +write out2.jpg \) -gravity southeast -compose over -composite \) \
3.jpg \
+gravity +append \
result.jpg
Re: How to work with files separately?
Thank you