APP: Show JPG Size

Started by Jingo, March 23, 2022, 05:48:59 PM

Previous topic - Next topic

Jingo

Howdy!  Was reading some board posts like I do throughout every day and ran across an interesting request here: https://www.photools.com/community/index.php?topic=12397

KKiel was looking for a way to determine what the file size of a full resolution JPG might be if the current TIFF image was converted without actually doing the conversion.

So, had some free time today and figured I would flex my programming muscles since it had been awhile since I did any IMatch coding.... and here is the result.. a quick and easy app to gather the filesize.

The all important App Icon!


The App window


As usual - just unzip the Show JPG Size.zip attached file into your: C:\ProgramData\photools.com\imatch6\webroot\user folder and IM will add it to the App Manager.     

NOTE: the app does rely upon the free ImageMagick tool which you will need to download and install: (https://imagemagick.org/script/download.php#windows) - I am using the latest version 7.1.0-28-Q16... the only important item is the install path which does need to defined within the program so it knows where to find the exe... if you are installing this same version using the default directory - you will be all set.  If you are using a different version or use a different path - then you will need to change two program lines (line #s 66 and 75) which identify the install path:


IMatch.processRun({
executable: 'C:\\Program Files\\ImageMagick-7.1.0-Q16-HDRI\\magick.exe',


This should work with most file types... I tried it with JPG->JPG, TIFF-> JPG and ORF->JPG.. they all worked.

Hopefully this software helps others.. even just to review the code and determine how to use command line software tools from within IMatch.  If you like this app - please check out my other contributions... as always.. major thx to Mario for creating such flexible software!

Any questions... please let me know!   Enjoy!! - Andy.


Mario

Thanks for sharing.
Maybe make the path to the executable a constant at the top of the app, to make it easier to adjust?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Quote from: Mario on March 23, 2022, 05:56:17 PM
Thanks for sharing.
Maybe make the path to the executable a constant at the top of the app, to make it easier to adjust?

I was trying to dynamically locate the path using the where cmd.exe command - but it is timing out in Imatch though running fine from the cmd prompt.. any thoughts?

IMatch.processRun({
                        'executable' : 'cmd.exe',
                        'parameters' : 'where magick.exe',
                        'showwindow' : false,
                        'timeout' : 30


via command line: C:\Users\fuego6\Downloads>where magick.exe
C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe

Mario

#3
Your example opens a command prompt and does NOT close it. So the call will hang forever...
You need to use /C of course.

See

cmd.exe /?

for details.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

ahhh... I'm so used to my own Angular JS enviroment and running things directly from the command line that I am overlooking the nuances from within the IMatch enviro...  Thx again - Andy.

Jingo

Well.. for some reason I just cannot get Imatch to recognize the where command via cmd.exe... works just fine in cmd and powershell.. but using the run code - it cannot locate the magick.exe file.  Strange because the same code will find the imatch executable - but even though magick.exe is in the PATH variable - it still cannot locate the directory. 

So - I think I'm going to leave this as is for now... the hardcoded path to magick.exe isn't elegant.. but I've spent hours trying to get it to locate dynamically using cmd/powershell to no avail.

(of course - I'm thinking Mario is going to shoot me a line of code that fixes it in 10 seconds...  8))

Enjoy everyone! - Andy.

kkiel

Dear Jingo, dear all,

thanks again for your dedication!

I tried to run the app and made sure that the image magick version and path are exactly what you wrote they should be.
The app run, but I did not get a number as result, see screenshot.

Is there anything else I can have overlooked?

Regards,

kkiel




Jingo

#7
Hmm... may I ask what type of source image you are using?  I tested it with TIFF, JPG and ORW (raw) files.. but if you are using say PSD - I didn't test that and perhaps I need to add some more logic to the Imagemagick command line.

If it is a TIFF or JPG file, can you try running the app in the browser, hitting F12 to open the developer menu, and go to the console tab... hit F5 to reload the app and try again.  Let me know if you see any errors show up in the console window.  The fact you are actually getting the text to appear leads me to believe the app is running successfully... so perhaps it is indeed the file type.

kkiel

Dear Jingo,

I tried with tifs, lzw-compressed or not, and can't get it to work. I'd like to try what you suggested, but, sorry for the silly question, how can I run your app in the browser?

Thank you very much!

Jingo

Hello... here is some info on running the app in the browser: https://www.photools.com/help/imatch/app_basics.htm?dl=h-6  - you basically just hover your mouse over the app icon to get to the hidden menu icon, then choose to run the app in the browser.

Also, if you could share one of the TIFF files, I'll load it locally and see if it will run in my app.  So long as the path to magick.exe is the same as in the browser - this should work without a hitch!

Jingo

Hi... I've been working with kkiel to troubleshoot an issue on their system where they are not getting the filesize reported for a TIFF image.  I have tried this on my system with the same image and it works correctly.  Was hoping we might have a few folks test the app on their system to see if it works correctly... especially someone with a German localization (I'm wondering if the c:\program files path to Magick.exe [c:\programme in German might be an issue?)

If it doesn't report the file size, if you can send along your console.log from the browser, that would be helpful.

Thx! - Andy.

Mario

Mabye try a v1/filesystem/file/info to check if magick.exe exists where you expect it to?
Maybe use the environment variable %PROGRAMFILES% to get the path instead of hard-coding?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Quote from: Mario on April 01, 2022, 03:04:34 PM
Mabye try a v1/filesystem/file/info to check if magick.exe exists where you expect it to?
Maybe use the environment variable %PROGRAMFILES% to get the path instead of hard-coding?

Thx Mario - I'll check into the info endpoint.. I tried to do this via a cmd from IMatch and mentioned earlier in the thread and even with the /C command - it won't successfully locate the Magick.exe.   I can use the same logic to find and return the location of the IMatch executable.. but it fails on Magick.exe and anything else in that folder.. I'm wondering it it doesn't like spaces in the path name or something? 

thrinn

Quote from: Jingo on April 01, 2022, 02:36:06 PM
Hi... I've been working with kkiel to troubleshoot an issue on their system where they are not getting the filesize reported for a TIFF image.  I have tried this on my system with the same image and it works correctly.  Was hoping we might have a few folks test the app on their system to see if it works correctly... especially someone with a German localization (I'm wondering if the c:\program files path to Magick.exe [c:\programme in German might be an issue?)

If it doesn't report the file size, if you can send along your console.log from the browser, that would be helpful.

Thx! - Andy.
Hi Andy,
I just tried you app and it works for me, at least for ARW files. I am using a German localization, so C:\Programme is not the culprit. In fact, the physical path is still C:\Program Files even on a German Windows, C:\Programme is only the textual representation.

I used the default to options to install ImageMagick which means that the executable is located at C:\Program Files\ImageMagick-7.1.0-Q16-HDRI.

Anything else I should try?
Thorsten
Win 10 / 64, IMatch 2018, IMA

Jingo

Thanks Thorsten... appreciate the time to install ImageMagick and do a test on a German localization.  I'm not too sure what else I can do help with this one besides a remote support session on kkiel's machine to monitor the console.log and debug as we go.  Must be something odd causing the hiccup. 

kkiel - just to confirm, you are using the most up to date version of Imatch at the moment?