Different result in Scripting |Run Scripts than run from CTB

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Different result in Scripting |Run Scripts than run from CTB

Post by klownboy »

Don, it was driving me crazy as to why a script I had been using nearly daily is now not working on certain images. Well I finally tracked it down. The exact same script run from Scripting | Run script... yields a different result than running/loading the same script file from a CTB. Now that shouldn't be! When I run this bastardized slimmed down version of the problem portion of the script on a Canon photo with a width of "2592" and a height of "3888", I get the correct result from the "Run script..." and the opposite result when run from a script loaded from a CTB - it yields a result of width 3888 and height 2592. WOW very weird. Don I'll send you the image if that's OK.

You may be thinking that's an odd ball situation or an odd ball photo, but no the photo is straight from a common Canon EOS. It appears to happening when the property "Orientation" is null or nothing as opposed to Normal or a Rotated value. In any case there's no way regardless that I should be getting 2 different results depending on whether I run the script from a CTB or from Scripting | Run script... Note: If you're using the German language you may have to change the property value or comment the line out. I think ImageX and ImageY should work regardless.

Code: Select all

  foreach($file, <get selecteditemspathnames |>) { 
     $p = property("#11", $file);   
   if ($p == "Picture") {
    $d = property("dimensions", $file);
    $rotate = property("#245", $file);
    $orig_width = property("ImageX", $file);
    $orig_height = property("ImageY", $file);
	echo Width: $orig_width   Height: $orig_height;
    }
  }
Hovering File Info Tips does get it right. I just sent the image. Thanks,
Ken

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Different result in Scripting |Run Scripts than run from

Post by admin »

Hm, tried it. Script yields same results in all contexts here.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Different result in Scripting |Run Scripts than run from

Post by TheQwerty »

Are you absolutely positive they are both running the same exact script?

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Different result in Scripting |Run Scripts than run from

Post by admin »

I tested with the central part:

Code: Select all

$orig_width = property("ImageX");
   $orig_height = property("ImageY");
   echo "Width: $orig_width   Height: $orig_height";

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

Why did I know this would happen! Were you testing in English language, etc?
Absolutely positive I was running the exact same script. To make sure, I copied the script from my "post" and ran it from "Run Script..." with the addition in the echo of "Run from Run Script" and did the same in a normal left click of a CTB with the addition in the echo of "Run from CTB". See the result.
WxH_run from CTB.PNG
WxH_run_from_Run_Script.PNG
By the way, the result from the CTB is the same whether I have the contents of the little script in left click edit box or if I have the script in a file that is loaded from the CTB left click. I can't think of any setting that should affect this result, can you? Anything I could do to further test? As I said before the File Info tips hover gets it right. I have checked image width and height and dimensions in Configuration. Thanks.

Edit: Don, I used the 3 lines you tested with and my results are the same as shown above. You might still have my XY ini file I sent a week ago for something else.
To see the attached files, you need to log into the forum.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Different result in Scripting |Run Scripts than run from

Post by Filehero »

Hi Ken,

can't confirm over here with a Pentax PEF and the CTB test using the copied RUN code pasted into the 'On left click' edit popup.

Hmmmm :?:

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

Maybe this will help track the issue down. I put the folder in a large tile view and as you can see in the capture, the info provided in large tile view is wrong 3888x2592 where as the info tip hovering on the tile thumbnail is correct 2592x3888.
WxH_Large_tile_view.PNG
Is it possible that scripting from Run script could be getting the width and height from one place (which is correct) and the scripting from the CTB is getting it from somewhere else (which is wrong)? And as I mentioned earlier, this only seems to happen when the "orientation" which I also have checked in "File Info Tips" is null or nothing instead of normal or a rotation value. As you can see "Orientation" does not show up in the info tip even though it's checked off in configuration since it's null with this picture.
To see the attached files, you need to log into the forum.

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Different result in Scripting |Run Scripts than run from

Post by Filehero »

Even with your last reproduction steps I don't seeany difference here. Maybe, you can put the image somewhere for public download?

Of course, you have already applied the most boring amongst the usual suspects-pattern known as ::fresh? :oops: & sorry

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

Thanks Filehero, silly me hadn't tried in a fresh copy, but I just did. Same result, incorrect in the CTB ran script and correct in the Scripting | Run Script.

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Different result in Scripting |Run Scripts than run from

Post by admin »

I can confirm that the tile view gets it wrong because it uses an ultra-optimized algorithm that does not know about rotated JPGs.

But this does not explain the differences in scripts. are the scripts really identical?

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

Definitely identical. I also copied your posted 3 liner shortened version and used it in "Run Scripts" and in a "CTB" both as a loaded script file and with the contents input in the CTB left click edit box and the results were still the same (i.e., different). I again did the same thing in a fresh copy with the same result. I know my PhotoCropping script worked fine (and with this image file type) for nearly the last 2 years and within the last couple months something went haywire and I hadn't been able to nail it down but I saw today stepping through the script that the widths and heights were messed up. Thanks, anything else I can try to nail it down? Did you still have my XY ini file I sent a week ago?

admin
Site Admin
Posts: 67282
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Different result in Scripting |Run Scripts than run from

Post by admin »

From my POV this is impossible. Just went through the code. There CANNOT be a difference. So it must be voodoo. Take care.

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

Don, impossible but it's happening. Do codecs come into play in this situation? I ask because both Irfanview and ImageEye file viewers get the dimensions right, but FastPictureViewer gets it wrong. I have the FastPictureViewer Pro Codec Pack installed and when I open that image in FastPictureViewer it's not rotated properly whereas it is in both ImageEye and Irfanview. Is it possible that the FastPictureViewer Codec Pack is somehow affecting the result? I don't want to uninstall unless you think it could be an issue.
Thanks

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

I know you're sleeping or should be, but I think I answered my question I asked in the previous post concerning whether codecs installed may be affecting the results I have more specifically codecs from FastPictureViewer. Well it does, but why should it Don if your coding is the same whether we run it from "Run Script" or from a "CTB"? That's the question.

I didn't uninstall the entire FastPictureViewer Pro Codec Pack. The install/remove in Control Panel does allow individual features to be changed so I uninstalled the 1st feature which is: "WIC - Enabled fast JPEG decoder with EXIF auto-rotation". Low and behold, after reboot both values from "Run Script" and from the CTB are both the same - 3888 for width and 2592 for width which is the opposite of what it should be for that portrait image, but at least it is consistent.
admin wrote:Hm, tried it. Script yields same results in all contexts here.
Don, are those the same values you came out with for the image I sent? I can't ask anyone else since they don't have the picture. So why would the codec affect the script running in one situation and not the other?
Thanks,
Ken

klownboy
Posts: 4481
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Different result in Scripting |Run Scripts than run from

Post by klownboy »

I forgot to mention in addition to what I stated above and as a follow-up incase someone else has a similar issue with the codecs from FastPictureViewer Pro Codec Pack, having the Jpeg decoder installed also removed the "Orientation" value for that particular photograph which was "Rotate 270 degrees". Now that I've uninstalled that codec, the value is back instead of being null. This is was messing up the script since it checks the "Orientation" value and acts accordingly to crop the photo.

Post Reply