Page 1 of 1

[solved]script not working anymore with NConvert

Posted: 26 Jul 2020 16:22
by lian00
Hello, I use this script associate with NConvert to put a random watermark image on an image. It worked nicely until some times. The only difference I see is XYplorer updates. Is there something in XYplorer code I should check. If everything is OK, I will ask on NConvert forum. Thanks for your answers.

When I run this code now, the watermark image is copied in image directory and nothing more.

Code: Select all

foreach($file, "<get SelectedItemsPathNames |>") {
	$rand = rand(1,5);
	$nomfichier = "G:\img-range\images-perso-xz\essai-cadre-"."$rand".".png";
	wait 1000;
    runret("""C:\Program Files\nconvert\nconvert.exe""-resize longest 500 -quiet -wmflag center -wmfile"." $nomfichier"." -D -out jpeg -o G:\img-range\images-perso-xz\alternative\%-alter.jpg""");
        wait 1000;
        }
 	end confirm ("Allez à Alternative ? !!PENSER à uploader l'image!!") == 0;
          goto "G:\img-range\images-perso-xz\alternative";

Re: script not working anymore with NConvert

Posted: 26 Jul 2020 17:05
by klownboy
It may not be the problem (I can't test), but you don't have a space after "nconvert quotes ...nconvert.exe""-resize and maybe there should be. As shown, I don't have any when I selected your text directly from the forum.

Re: script not working anymore with NConvert

Posted: 26 Jul 2020 17:15
by lian00
You are right. But after correcting this, it’s not better. The script goes to the end (with message) but the file is not created. In fact, I did try to modify to change the code from working code (always calling NConvert) as I had the "no file created" problem. So the missing space was coming from my tests. But the original problem is still there. Very frustrating.

Re: script not working anymore with NConvert

Posted: 26 Jul 2020 17:38
by highend
You're looping over selected images which are addressed by $file and then don't use $file in the loop?
So how should nconvert know what file to process?
This worked nicely (some time ago)? I doubt this.

Apart from that, the quoting is wrong at the end of the runret command...

Re: script not working anymore with NConvert

Posted: 26 Jul 2020 18:03
by lian00
Thanks for pointing all the problems. And you are right, I remember now that my old code did not work anymore and tried to adapt this one. But I did not keep the old working/no more working code. Too bad.

Code: Select all

"Redim 1200"
	 foreach($file, "<get SelectedItemsPathNames |>") {
        $ext     = gpc($file, "ext");
        $oldName = gpc($file, "base");
        $newName = replace(recase($oldName, "lower"), " ", "-");
        rename "s", "$oldName/$newName";
        runret("""C:\Program Files\nconvert\nconvert.exe"" -ratio -rtype lanczos -rflag orient -quiet -resize longest 1200 -out jpeg -o ""G:\images\Output\%.jpg"" ""<curpath>\$newName.$ext""");
    }
    end confirm("Allez à Output ?") == 0;
    goto "G:\images\Output";
This one works perfectly and there is no call to $file in NConvert. Sorry, I don’t master this at all.

Re: script not working anymore with NConvert

Posted: 26 Jul 2020 18:32
by lian00
Thanks to @highend, I added the call to $file and it works now. I don’t know how I missed that in my tests.