Need to randomley ShearRotateImage in Folder

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?".
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

I am having trouble getting Imagemagick to do this. This is what I have so far. I need to select any file that has *.jpg and randomly rotate and shear the images within 10 degrees.

Help

magick /Users/Username/Desktop/folder/*.jpg ShearRotateImage(const Image *jpg,"%[fx:-1+2*rand()]")
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to randomley ShearRotateImage in Folder

Post by fmw42 »

Your syntax is bad. You are mixing command line and API code. Also you cannot use wild cards for both input an output. You should use magick mogrify to process a folder of images. But mogrify is old technology and does not allow inline computations. So you will likely need to write a script loop over each image and process them that way. Then you can do

Code: Select all

magick image.jpg -alpha on -background none -shear "%[fx:10*(-1+2*rand())]x0" image.png
see https://imagemagick.org/script/command- ... .php#shear


____________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.


If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

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/script/porting.php#cli
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

magick /Users/username/Desktop/MM10918\ copy /image.jpg -alpha on -background none -shear "%[fx:10*(-1+2*rand())]x0" image.jpg
magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/556.


I keep getting this error?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to randomley ShearRotateImage in Folder

Post by fmw42 »

What is your IM version and Platform/OS? If a Unix system, I can help with the script loop. If on Windows, then someone else would have to help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to randomley ShearRotateImage in Folder

Post by fmw42 »

Filenames with spaces need to be put in double quotes. You are also mixing \ and /. For Unix, only use /

Code: Select all

magick "/Users/username/Desktop/MM10918/ copy /image.jpg" -alpha on -background none -shear "%[fx:10*(-1+2*rand())]x0" image.jpg
Or do I misunderstand your \ copy /
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

I am using V7 on High Sierra. Yes there are spaces in the file names
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

magick "/Users/celvenjohnson27\ 1/Desktop/MM10918\ copy/image.jpg" -alpha on -background none -shear "%[fx:10*(-1+2*rand())]x0" image.jpg

Im using this but getting the same error directory @ error/blob.c/OpenBlob/348
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

Does this apply to all the .jpg files in the folder?
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

Does this apply to all the .jpg files in the folder?
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

unable to open image . this is the error Im getting
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

I got the path to work, Im not sure it is working though? They do not look rotated or sheared?
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

Version: ImageMagick 7.0.8-12 Q16 x86_64 2018-09-23
Using Mac
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to randomley ShearRotateImage in Folder

Post by fmw42 »

Cd to the directory where you have your input and try it there

Code: Select all

magick image.jpg -alpha on -background none -shear "%[fx:10*(-1+2*rand())]x0" image.png
Does that work?

What exact version of IM 7?

Code: Select all

magick -version
If you file path actually has \ then use your actual file path but put double quotes about it. But are you sure about the path? Why do you want spaces. That just makes it more confusing. I do not advise doing that. But it should work if you have the correct path and use quotes.
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

Version: ImageMagick 7.0.8-12 Q16 x86_64 2018-09-23
celvenjohnson33
Posts: 12
Joined: 2018-10-10T09:26:59-07:00
Authentication code: 1152

Re: Need to randomley ShearRotateImage in Folder

Post by celvenjohnson33 »

this is the error I get now after i cd the directory

magick: unable to open image 'image.jpg': No such file or directory @ error/blob.c/OpenBlob/3489.

the files are formatted as "yyyy-mm-dd-hh-mm-ss.jpg"
Post Reply