#1 2011-07-21 00:19

Tatjana
Member
From: Portugal
Registered: 2011-01-16
Posts: 5

Is it possible to append to jpg names the number of unique colors?

I am sorry if I am pushing a bit too much but it seems to be all possible using this amazing tool!

When I have a jpg and re-save it, no matter how high I tell the program I want the quality, the edges are blurred, what will make that the re-saved JPG has more unique colors than original.

Any thoughts? smile

Thanks in advance,

Your big fan

Tatjana

Offline

#2 2011-07-21 06:23

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Is it possible to append to jpg names the number of unique colors?

JPG is a lossy format, so every time you re-save it, you'll lose quality. You have to first see whether it is really necessary to re-save it or not.

Instead of ReNamer doing this itself, I suggest you look into some other tool which you can call to get the desired output. For example, a quick search pointed me to ImageMagick's Identify command-line utility, which has an option to print the number of unique colors in an image.

Offline

#3 2011-07-21 07:11

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Is it possible to append to jpg names the number of unique colors?

How is the subject " Is it possible to append to jpg names the number of unique colors? "

related to this question?

Tatjana wrote:

When I have a jpg and re-save it, no matter how high I tell the program I want the quality, the edges are blurred,
what will make that the re-saved JPG has more unique colors than original.

Please note that ReNamer will not modify the content of an file, only because the file name will be changed.
So i think not that ReNamer is the tool who "re-save" an picture and "blurred  the edges".
I guess you do something other then renaming only. Or you are in the wrong forum here for that question?


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2011-07-21 09:53

Tatjana
Member
From: Portugal
Registered: 2011-01-16
Posts: 5

Re: Is it possible to append to jpg names the number of unique colors?

I am sorry, I was too tired. I need to prefix a bunch of jpg images with the number of unique colors.
I was not in the wrong forum, but the way I post my message it looked like I was.

I have ImageMagik but I don't know if it is possible to use it with ReNamer, making ReNamer call it and get it's output.
That was my original Idea, but I don't know if it is possible.

Your quote and how it relates to the subject, was my way to express why I wanted to prefix or append the unique colors to a jpg filename, it's related to it's quality when compared to very similar ones.

Thank you for your help Stefan.

Tat

Offline

#5 2011-07-21 10:25

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Is it possible to append to jpg names the number of unique colors?

Ah now i understand the relationship ;-) , make sense, thanks for clarifying.

I have no time to test but it should be possible via  ExecConsoleApp():

ExecConsoleApp( vApp, vOut)
will call the vApp for each file and put the result in var vOut.
Then we have to parse the vOut by an RegExp for the needed info and use that to modify the file name.

Just search for "Exif2 den4b ExecConsoleApp" or like that to see some examples.

Maybe someone is willing to help here,... or i take an look if i am not that busy anymore.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#6 2011-07-21 14:48

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Is it possible to append to jpg names the number of unique colors?

Ah, BTW
We need the info which tool can be used to get the "number of unique colors" from an picture.
And how is the command line to use? Just the one used e.g. in an DOS-Box. Then we can use this in an PascalScript.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#7 2011-07-22 06:02

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Is it possible to append to jpg names the number of unique colors?

Stefan wrote:

Ah, BTW
We need the info which tool can be used to get the "number of unique colors" from an picture.
And how is the command line to use?

I did the basic search and posted the relevant link in post #2 above. If the OP cares to check the link, the command-line will be revealed, so I don't see what the problem is, other than calling it from ReNamer (for which you, i.e. Stefan, have already given the necessary hints). That Exif2 example should be sufficient to get started and learn how to call an external utility from within the program.

Offline

#8 2011-07-23 02:12

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Is it possible to append to jpg names the number of unique colors?

You are right Andrew, all parts are given, but it takes some more then that to solve the puzzle.

So i toke an look how the solution could be, but failed myself half the way.

First i have downloaded ImageMagick (45MB ?!) and searched how to get the wanted result; amount of unique colors in file.
An goggle search was the easiest way, since the online help was way to much.

I found this command line will do the work:

"path\to\ImageMagick\identify.exe" -unique -verbose images\atop.gif | find "Colors:"
   Colors: 55




But trying that from ReNamer lets ReNamer freeze (no response)
"path\to\ImageMagick\identify.exe" -unique -verbose "path\to\ImageMagick\images\atop.gif"  | find "Colors:"




I tested it with this piece of code:

//Original command: "path\to\ImageMagick\identify.exe" -unique -verbose path\file.ext | find "Colors:"
//Results in:  Colors: 55

const
  appl = '"e:\ImageMagick\identify.exe" -unique -verbose ';
  find = ' | find "Colors:"';

var
  Command, Output: String;

begin
  //maybe here: check first if extension is supported


  //execute the command line on current file:
  Command := appl + '"'+FilePath+'"' + find;
  ShowMessage(Command);
  

  //if shell returns errorlevel 0:
  if ExecConsoleApp(Command, Output) = 0 then
  begin
     //drop "Colors: " part 
     Delete(Output,1,8);
     ShowMessage(Output);
  end;


  //generate new filename:
  //FileName := Output + ' ' + FileName;

end.

The same freeze i got without 'find' too.
I will try to investigate some more....


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#9 2011-07-23 16:42

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: Is it possible to append to jpg names the number of unique colors?

Did you try executing the same command in the command prompt?

Beware: If you run a console app which requires user input from PascalScript rule, it will freeze! Pipes might also cause problems.

Offline

#10 2011-07-23 17:15

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: Is it possible to append to jpg names the number of unique colors?

Seems to hang when you add GIFs, but works fine with JPGs. No idea why, since Identify works fine with the same GIFs when run directly from the command-line. So maybe something's the matter with ExecConsoleApp() and ReNamer.

P.S. No pipes used, just identify -verbose -unique <filename>

Last edited by Andrew (2011-07-23 17:16)

Offline

Board footer

Powered by FluxBB