Find poor images by "pixel per byte"

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
Thany
Senior Member
Senior Member
Posts: 241
Joined: 2003-09-30, 09:20 UTC
Location: Netherlands

Find poor images by "pixel per byte"

Post by *Thany » 2012-09-25, 21:55 UTC

I'm currently trying to figure out how to get a column with information on the apparant quality of images. I'm trying to make a rough guesstimate on how aggressively an image is compressed combined with how much unique information can be found inside.

Images that are big in dimensions but small in filesize are considered not good; images that are big in filesize, but small in dimensions are considered extremely good. These will be the two extremes of the spectrum, i.e. from solid white png to losslessly compressed photographs. I'd like to see a number that identifies something between these two extremes.

My first guess on how to do that, is rather simple: pixelwidth*pixelheight/filesize. But I can't find a way to do that, not even using this excellent plugin. I kind of assumed the custom columns allowed for simple expressions, but it seems not.

First question: any quick way of getting the result of width*height/size in a custom column?
Second question: any better ways of assessing image quality? (of course, disregarding JPEG compression - that is mostly useless)

Thanks :)

User avatar
EricB
Senior Member
Senior Member
Posts: 333
Joined: 2008-03-25, 22:21 UTC
Location: The Netherlands

Post by *EricB » 2012-09-26, 07:35 UTC

Hi Thany,

It also depends on the type of images you have in a folder. If you have a mixture of photos and other type of pictures, like banners (e.g. you ripped a whole website) then you can use ratio (width/height) to determine if the picture is worthwhile. Normally a (standard) photo never exceeds the 1.6 or goes under 0.6, while banners are often above or under those values. Thumbnails of photos is hard, most of time only file size and picture dimensions together are decisive.
I'm also using Wdx4i to get mentioned values.

Regards, EricB

Thany
Senior Member
Senior Member
Posts: 241
Joined: 2003-09-30, 09:20 UTC
Location: Netherlands

Post by *Thany » 2012-09-26, 10:26 UTC

Thanks for the thought.
Aspect ratio I've already filtered out, and I decided to keep anything between 0.4 and 2.0, so a bite more generous :)
I'm still really looking for this guesstimate of photographic quality, i.e. the number of pixels that go in a byte (or kilobyte). More "pixels per byte" denotes a lower quality, i.e. higher jpeg compression, less unique information, or multiple lossy saves.

I know this is not a solid way of filtering out low qualities, but a guesstimate is good enough for my purposes.

User avatar
ZoSTeR
Power Member
Power Member
Posts: 920
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR » 2012-09-26, 13:39 UTC

Have a look at Identify from ImageMagick.

It tells you the Jpeg quality percentage among other things.
You could write that into a descript.ion file with a batch:

Code: Select all

for %%i in (*.jpg) do identify.exe -format "%%f %%C %%Q" %%i >>descript.ion
After that enable comments in TC (Ctrl+Shift+F2)

Thany
Senior Member
Senior Member
Posts: 241
Joined: 2003-09-30, 09:20 UTC
Location: Netherlands

Post by *Thany » 2012-09-26, 13:50 UTC

Thanks, but like I said, it's not the JPEG quality I'm looking for. I'm looking for visual quality, not compression ratio. For jpeg (and jpeg alone) the quality setting can be 100% and still produce a very bad quality image (i.e. many pixels per byte) and it was re-saved from an original image that had quality=10%.

Also, your solution doesn't cover PNG, GIF and other lossless formats. PNG can also achieve quality that for my purposes would be considered "bad", when for example it's a solid white image (which will produce many pixels per byte). A much more complex drawing that therefor has much more unique pieces of information, will produce a larger file (less pixels per byte) and be considered "good" in y scenario.

So I think I really need something like "number of pixels per byte" :)

User avatar
nsp
Power Member
Power Member
Posts: 1195
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp » 2012-09-27, 10:02 UTC

Thany wrote:
So I think I really need something like "number of pixels per byte"
The solution provided using identify goes in the right direction !

Code: Select all

@REM calculate Pixel per byte
@echo off
del descript.ion
for %%i in (*.jpg *.png *.gif ) do identify.exe -format "%%f %%[fx: %%~zi / ( w  * h )]" %%i >>descript.ion
%%~zi is the file size in byte
fx:.... allow identify to do calculations
w * h is the number of pixel
..... give a look to batch scipting and imagemagick documentation.

With this script you calculate what you want. In user column, you can add "Pixel per Byte" as tc.comment and filter, sort,....

You can also take into account the number of colors in the image and about subjective image quality you can also take into account medium size of connected pixels (not as easy to calculate without real image processing programming)...

Thany
Senior Member
Senior Member
Posts: 241
Joined: 2003-09-30, 09:20 UTC
Location: Netherlands

Post by *Thany » 2012-09-27, 11:14 UTC

Oh wow, well I had never know it's that powerful. I don't quite understand the expression, but if you say it works, I'll believe it :)

I'll test it out soon and let you know :)

User avatar
nsp
Power Member
Power Member
Posts: 1195
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp » 2012-09-27, 13:15 UTC

Thany wrote:Oh wow, well I had never know it's that powerful. I don't quite understand the expression, but if you say it works, I'll believe it :)

I'll test it out soon and let you know :)
You should try to understand the expression if you wan t to adapt it.

First install imagemagick bundle and verify that convert, mogrify and identify command lines are in the path. (This is one of the most powerful image processing set of command line tools)

Create a batch script used to initialize descript.ion files in each image folder. (if you already set comment using descript.ion file you must save it first or you will loose all using the script). For more info on batch scripting, you get a lot of info here
You can set a em_command targeting your script and use it as a hotkey or a button

Download ImageMagic

Read documentation of identify, -format escapes and %[fx:....

User avatar
ZoSTeR
Power Member
Power Member
Posts: 920
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR » 2012-09-27, 13:52 UTC

One quick tip for understanding the expression: the %%~zi variable (file size) gets filled by the For command and is not part of the Identify variables.

User avatar
nsp
Power Member
Power Member
Posts: 1195
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp » 2012-09-27, 14:58 UTC

ZoSTeR wrote:One quick tip for understanding the expression: the %%~zi variable (file size) gets filled by the For command and is not part of the Identify variables.
You got it :) %%f and %%[ is to get %f and %[ for identify command . (usually % is used in command line and %% inside batch file)

Thany
Senior Member
Senior Member
Posts: 241
Joined: 2003-09-30, 09:20 UTC
Location: Netherlands

Post by *Thany » 2012-09-27, 19:14 UTC

Oh yes I see it now. those parts are just standard batch derived variables. I guess I forgot about the filesize one, because I've never had to use it.

As for the identify.exe trick, I promised to check back. It works :)
filsize/pixels is actually better than pixels/filsize, because it gives a number lower than 1 (usually, in my case) which doesn't absolutely require numeric sorting.

It does what I need for now, but whenever I need something more, I'll know where to look. Thanks!

User avatar
van Dusen
Power Member
Power Member
Posts: 683
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

Post by *van Dusen » 2012-09-27, 23:06 UTC

Hello Thany,

give the ImagePrintsize.vbs script for the content plugin ScriptWDX a try: It supports calculated values for
%bytPerPixFile% ... Bytes per pixel (based on "gross" filesize - that's the filesize in bytes as shown in TC, thus size for pure image data plus size of metadata (like EXIF information) plus other "overhead" (like file header and so on))
%pixPerBytFile% ... Pixel per byte (based on "gross" filesize)
%bytPerPixImg% ... Bytes per pixel (based on "net" filesize - that's "gross" filesize minus size of embedded metadata)
%pixPerBytImg% ... Pixel perbyte (based on "net" filesize)

You can define one or more colum definitions for a custom column view and assign one or more result strings from the script to these columns. By default, the script returns a formatted string in the form
"%bytPerPixImg% b/Pix • %pixPerBytImg% Pix/b • Comp: %imgComp% • Q: %imgQual%"
in "Result2"

See http://www.ghisler.ch/board/viewtopic.php?t=9986 for further details (it's on the german board, but - if needed - google translate may help... or just ask here for help :-)

Post Reply