ImageMagick & XYplorer

Discuss and share scripts and script files...
totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

ImageMagick & XYplorer

Post by totmad1 »

I had looked at ImageMagick a few years ago and realised, what a great program.
I tried the windows version but found it wouldn't work the way I wanted.
A few days ago I decided to try it with XY. What an eye-opener.
You could write a batch file to alter all of one format in a folder.
That was not what I wanted, step forward XY.
With these scripts YOU choose which images are worked on.
Exactly what I wanted. Hope it's what you are looking for.
These scripts are only a small amount of what is possible.

After download http://www.imagemagick.org/script/binar ... hp#windows install and do a restart.
There is a portable version listed last
please NOTE spaces in image names or paths are NOT tolerated.

I have not been able to use "import" , "display" or "animate".
Error comes up "no x-server" of course, why put them in for windows?

1st image shows initial popup, these are non-ImageMagick.
Which I've found useful, not just on images.
1st.jpg
1st.jpg (15.52 KiB) Viewed 6898 times
2nd image is the ImageMagick menu, should be self explanatory.
Please ask for clarification or help if required.
ImageMagick.jpg
ImageMagick.jpg (44.23 KiB) Viewed 6898 times
ManNoSort-ImageMagick.xys
(9.19 KiB) Downloaded 438 times
totmad1 (totally mad one)

binocular222
Posts: 1418
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: ImageMagick & XYplorer

Post by binocular222 »

FastStone Viewer can do all these things, with a nice GUI
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: ImageMagick & XYplorer

Post by totmad1 »

I have the greatest respect for you binocular222 . I know you are a better scripter than me , so maybe I am missing something in FastStone Viewer.
I don't seem to be able to split a list of images by 50% in either direction ,only take a slice of the centre in FSV.
I have looked at a number of program to do this for one reason .
I scan in my books and then have to split the image to get each page individually.
If you could point the way to a better solution please do so.
Up til now I have been using PhotoBatch from Geek.com but you can't do a 50% split, you have to check each book.
And also with PhotoBatch you make a list of images .
totmad1 (totally mad one)

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

Hi totmad1, thanks very much for this. I haven't checked it out completely yet, but you mentioned in the post that it doesn't accept spaces in the file names or paths. I think that can be easily resolved by the quoting in the running IM (convert) lines. You can also add the no wait and no show parameters to the run line such that you never see the pesky command box flickering. Something like this seems to work just fine...no flickering box and it accepts spaces (double quotes are your friend) :D

Code: Select all

run ("cmd /c $p_convert -define  jpeg:size=$wh ""$Item"" -thumbnail $wh -gravity center -extent $wh2 ""crop_$base"""), ,2,0;
About a year and a half ago I posted something along these lines which crops my photos to 4 different aspect ratios of the different monitors I have (or my kids have). I have since expanded it quite a bit, and I have also have a version which uses IM in lieu of Irfanview command lines. Photo Cropper http://www.xyplorer.com/xyfc/viewtopic. ... =photocrop It allows you to adjust where you want to make the crop within the photo (i.e., the primary crop location - top/bottom or left/right) and in the newer version, it also allows you to first take a cut from the non-primary crop sides. All of which depends on the picture's original aspect ratio.
Anyway, I totally agree about Image Magick. It's a powerful program though the command lines can be a bit overwhelming, and as you've probably already figured out, it takes even longer melding it into XY scripting. It's well worth it once you do it though.
Thanks again,
Ken

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: ImageMagick & XYplorer

Post by totmad1 »

Thanks for the comments klownboy(Ken) Its much appreciated.
I can't believe I relied on ImageMagick's forum which had a topic on spaces and dots,
saying they had tried their recommended solution which hadn't worked.
I had tried their solution (didn't work) and had forgotten the double quote power in XY.
So once again a big thanks.
totmad1 (totally mad one)

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

You are quite welcome. I only knew since I had already spent quite a bit of time toying with Irfanview and Image Magick command lines. I recall it being a nightmare!
Ken

Stef123

Re: ImageMagick & XYplorer

Post by Stef123 »

Wish I'd come upon this script sooner. Ran into it just now thanks to highend's script overview.
It's loaded with stuff I can learn from in terms of XY scripting.

I am not familiar with ImageMagick. Judging from the sheer size of the portable download it's probably far superior to NConvert, an XNView off-spin I had used in the past. It weighs in at a mere 3MB. Need to compare features and run some standard tasks with both tools. Your script makes a great template for command line calls.

Thanks a ton. :)
Stef

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: ImageMagick & XYplorer

Post by totmad1 »

Hi Stef
Glad you like. Had fun doing this script(s). I must admit that I find command line scripts
most interesting. I picked up a lot from a 7z script I adjusted. Still have some problems but
when I do I fall back on using the Heredoc method.
p.s. I still use xnview .
totmad1 (totally mad one)

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

Hi totmad1 (or anyone else), I know you've obviously you've done quite a bit of work with ImageMagick in XY. I was wondering if you ever tried to set desktop wallpaper with an IM command line, probably using "display.exe". I've been attempting but I've had no success. Actually, I'm not even sure if it's possible. I'm doing an update to my old PhotoCropper script and will post soon. I've included many new options and it will use either ImageMagick or Irfanview, set by user selection on first run. It's quite simple to set wallpaper via command lin in Irfanview, but with IM, I'm not so sure. I've been Googling it but no luck yet. Do you know if it's even possible to do it with IM command lines 'alone'. Here a small excerpt of that portion of the script...only one of the many attempts.

Code: Select all

"Set current file as Wallpaper|<xyicons>\wallpaper_01.ico"
      global $choice, $graphics;  
    If($choice LikeI "convert") {$display = getpathcomponent($graphics, "path") . "/display.exe";
       $bmp_name = trim("<curitem>", "jpg", "R") . "bmp";
        run "cmd /c ""$graphics"" ""<curitem>"" ""$bmp_name""", , 2,0;           //converting to bmp just in case it needs to be in lieu of jpg
	     run "cmd /c ""$display"" -backdrop ""bmp_name"" -window root", , 2,0; }  //$display being the IM's full path of "display.exe" 
    elseif($choice LikeI "i_view32") {
	     run """$graphics"" <curitem> /wall=3 /killmesoftly", , 2,0; }
    else {msg "The script uses either ImageMagick or Irfanview to set the desktop wallpaper.<crlf> Please reset global variable $graphics to NONE and rerun script.";}
Everything in the main portion of the script using either IM or IV is working. That was quite a chore especially since I'm allowing a user adjustable secondary crop to be performed before the adjustable primary crop which actually takes it to the aspect ratio selected. What a nightmare...
Thanks,
Ken

highend
Posts: 14195
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: ImageMagick & XYplorer

Post by highend »

Ken,

display (from ImageMagick) doesn't work on a windows os, it's written for X servers (unix world)...

You need a powershell script to change the wallpaper without logging off and on on a modern OS (e.g. 8, 8.1):
http://stackoverflow.com/questions/1972 ... ows-7?rq=1
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

Thanks highend, I was expecting that answer. I knew IM was Unix based so I started to wonder whether it was even possible in Windows, especially since I didn't run across any examples to do so. I stumbled across a number of sites with alternate means like the one you referenced. They all involve changing the registry either directly or via powershell or other command line which I'd rather not do in a script...just in case. Even though I can do it with IrfanView quite easily I may remove it from the script since I wanted everything to work using either Irfanview or ImageMagick.
Thanks again,
Ken

highend
Posts: 14195
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: ImageMagick & XYplorer

Post by highend »

Irfanview changes the registry as well :)

I don't think it's a bad thing to modify the registry with what's Windows providing with (build in) tools (at least regarding PowerShell from 7+)
and it's only a single value there isn't any chance to corrupt the system with it.
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

I have changed my mind on using PowerShell. I was under the impression that it wasn't included with XP and was concerned it wouldn't work for many users. After doing a bit of research though I found out it is . I made up a script using the powershell via heredoc and writing the ps1 file and then running it and it workd great though I did have to change the paramenter from "0" to "2" to get proper shrinking of the large images. It doesn't need a conversion to BMP either.

Question though, in Windows 7 x64, I see Powershell is off the system32 folder, "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" and the x86 compatible version is in wow64, "%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe" For me the script works by simply calling out powershell.exe via the run command since it's in the path. Would I be safer for fuller compatibility to use %winsysdir% or do I need to find out whether the user are using 32 or 64 by using %osbitness% ? This works fine...

Code: Select all

  run ("%winsysdir%\WindowsPowerShell\v1.0\powershell.exe ""<xyscripts>\tempPS.ps1"""), ,2,0;
but then again "PowerShell.exe" also works. The following does not work.

Code: Select all

 run (%winsysnative%\WindowsPowerShell\v1.0\powershell.exe ""<xyscripts>\tempPS.ps1"""), ,2,0;
Thanks.

highend
Posts: 14195
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: ImageMagick & XYplorer

Post by highend »

In this case it doesn't matter what you use.
Why?

The desktop wallpaper path is stored in
<root key>\Control Panel\Desktop

Wow6432Node redirection isn't active at this level so it's irrelevant if x86 or x64 powershell is used.
run (%winsysnative%\WindowsPowerShell\v1.0\powershell.exe ""<xyscripts>\tempPS.ps1"""), ,2,0;
And you are sure that the %winsysnative% folder really exists?

Open a command prompt and use:
cd "%windir%\sysnative"

Does it say it can't find the path?


There is one thing you can run into trouble with: script execution policy (powershell)...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4326
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.3915 at 100% 2560x1440

Re: ImageMagick & XYplorer

Post by klownboy »

Yes, it says it can't find the path specified. I see a system32 and syswow64. So that's explains why %winsysnative% doesn't work. %winsysdir% used as follows works fine...

Code: Select all

run ("%winsysdir%\WindowsPowerShell\v1.0\powershell.exe ""<xyscripts>\tempPS.ps1"""), ,2,0;
On script execution problems, are you talking about the situation where a user is not running with elevated rights?

Post Reply