Page 1 of 1

use identify and convert in same command? mpr: format. windows batch file.

Posted: 2016-12-07T14:03:32-07:00
by josephaaroncampbell
Hello,

Is it possible to use the covert and identify commands in the same command string?

I need to apply settings to an .tiff image file but also want to know the mean and other stats about the images AFTER the settings are applied.

I was hoping to avoid writing the file to disk.

I tried the mpr: format hoping this would work but it did not.
I tried the -write command but maybe dont understand it very well.

so example:

-the settings i am applying in the normal covert command:

Code: Select all

magick convert -quiet -colorspace GRAY  -gamma %gNum1%  -sigmoidal-contrast  %fact%,%sNum1%%%  +level 0%%,98%%  -depth 8 %fullPathtoTIFF%  output.tiff
-then to use identify

Code: Select all

magick identify output.tiff -format "Mean1=%%[fx: mean]" xc:

I have tried to string them together but i get errors sting 'identify' is not a recognized command... for example

Code: Select all

magick convert -quiet -colorspace GRAY  -gamma %gNum1%  -sigmoidal-contrast  %fact%,%sNum1%%%  +level 0%%,98%%  -depth 8 %fullPathtoTIFF%  mpr:holder ^

identify mpr:holder -format  "Mean1=%%[fx: mean]" xc:

I've checked the batch usage page and am reading through some if its content. but is there a way to load an edited image into memory and return its mean or statistics without saving the file to disk?

Thank You.

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2016-12-07T14:48:51-07:00
by snibgo

Code: Select all

magick convert -quiet -colorspace GRAY -gamma %gNum1% -sigmoidal-contrast %fact%,%sNum1%%% +level 0%%,98%% -depth 8 %fullPathtoTIFF% output.tiff
That command is bad syntax. You should read the input, then process it, then write the output.

Code: Select all

magick convert -quiet %fullPathtoTIFF% -colorspace GRAY -gamma %gNum1% -sigmoidal-contrast %fact%,%sNum1%%% +level 0%%,98%% -depth 8 output.tiff
"+write info:" will write whatever info is in the current format string, so you can put that before the output image filename.

Code: Select all

magick convert -quiet %fullPathtoTIFF% -colorspace GRAY -gamma %gNum1% -sigmoidal-contrast %fact%,%sNum1%%% +level 0%%,98%% -depth 8 -format "Mean1=%%[fx:mean]\nStdDev=%%[fx:standard_deviation]" +write info: output.tiff
You can wrap that inside a FOR loop to get environment variables called "Mean1" and "StdDev".

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2017-02-12T22:56:15-07:00
by josephaaroncampbell
Thank you for the response. sorry for the delay in mine.

this works very well.

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2017-02-12T23:06:19-07:00
by josephaaroncampbell
I also ended up using the mpr format with '-write' like this:

**from windows batch file:

Code: Select all

 magick convert -quiet !fullpath! %~dp0clut.tif -clut -colorspace gray -gamma !gNum! -gravity center -crop 60%% -write mpr:hgram +delete mpr:hgram -format %%c histogram:info:- >> %~dp0hist.txt
this is to output the histogram data as if edits were applied to image to see how the edits effect the image data.

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2017-02-13T00:17:17-07:00
by snibgo
That will work fine, but this sequence:

Code: Select all

-write mpr:hgram +delete mpr:hgram
... is entirely redundant. It takes a little time but does nothing useful.

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2017-02-13T00:19:42-07:00
by josephaaroncampbell
I will test it out. I was doing it without the mpr before but didnt see any changes in the histogram. so maybe i was overlooking something then.

thanks for the info

Re: use identify and convert in same command? mpr: format. windows batch file.

Posted: 2017-02-28T11:11:50-07:00
by josephaaroncampbell
confirmed. This works just fine with out the added MPR.

Thank for making this more efficient.