Hi there,
I have the need to rotate pairs of images, stitch them horizontally and then crop to a certain size. Currently I'm doing this one step at a time and producing lots of excess images as my attempts to pipe outputs is failing me. I'm trying to do something like the following in Powershell:
magick (convert "d:\a folder with spaces\01022017083759_01.jpg" -rotate 270 -quality 100 "d:\a folder with spaces\rotated\01022017083759_01_rot270.jpg") (convert "d:\a folder with spaces\01022017083759_02.jpg" -rotate 90 -quality 100 "d:\a folder with spaces\rotated\01022017083759_02_rot90.jpg") "d:\a folder with spaces\rotated\01022017083759_02_rot90.jpg" "d:\a folder with spaces\rotated\01022017083759_01_rot270.jpg" +append miff:- | magick - -crop 7633x5767+1975.5+1460.5 +repage "d:\a folder with spaces\cropped\01022017083759_cropped.jpg"
This command runs, but seems to just go forever, hogging CPU resources. Each individual command works fine on its own, outputting to jpegs. What am I doing wrong?
Rotating, merging and cropping batch of images
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Rotating, merging and cropping batch of images
Do you want to keep the intermediate files? Why are they JPG format? I don't see why you are piping at all. There is only one image, so that can be cropped in the same command as the append.
If you don't need the intermediates, then this does the job. For clarity, I simplify the filenames.
If you do want to keep the intermediates, insert "+write temp_rotX.jpg" at any places you want within that command.
If you don't need the intermediates, then this does the job. For clarity, I simplify the filenames.
Code: Select all
magick ( 9_01.jpg -rotate 270 ) ( 9_02.jpg -rotate 90 ) +append -crop 7633x5767+1975.5+1460.5 +repage out.tiff
snibgo's IM pages: im.snibgo.com
Re: Rotating, merging and cropping batch of images
Thanks for the suggestion, but I get an error on the rotation when I try that:
I am not interested in the intermediary images, I only create them at the moment as it's the only way I can get the process to work!
Code: Select all
You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:
+ magick ( "01022017083759_01.jpg" - <<<< rotate 270 ) ( "01022017083759_02.jpg" -rotate 90 ) +append
-crop 7633x5767+1975.5+1460.5 +repage "cropped\01022017083759_cropped.jpg"
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Rotating, merging and cropping batch of images
The version I showed is for the Windows command line. Sorry, I don't use Powershell, and don't know how to write it in a way that Powershell understands, or what escapes Powershell might need for the parentheses etc.
snibgo's IM pages: im.snibgo.com
Re: Rotating, merging and cropping batch of images
Ah so it's a Powershell issue not Imagemagick? That narrows it down at least, thanks!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Rotating, merging and cropping batch of images
Yes, the error messages are coming from Powershell. Sorry, I can't help with that. When you get it working, I encourage you to post it here, to help other people who use IM in Powershell.
snibgo's IM pages: im.snibgo.com
Re: Rotating, merging and cropping batch of images
So Powershell was reading the brackets as special characters rather than literals, which was easy enough to solve by escaping with `. The bit that stumped me was that it still didn't work for some mysterious reason. Turns out Imagemagick doesn't like it if your brackets don't have spaces around them...
The following ridiculously simple line now works perfectly in Powershell:
The following ridiculously simple line now works perfectly in Powershell:
Code: Select all
magick 'img1.png' -rotate 90 `( 'img2.png' -rotate 270 `) +append -crop 124x62+62+31 +repage 'out.png'