follmann / favicon_maker

Create favicon files in various sizes from a base image for ruby projects
MIT License
70 stars 7 forks source link

favicon_maker changes colorspaces when converting png-Files with or without middleman #16

Closed karland closed 10 years ago

karland commented 10 years ago

Hi,

I am using middleman-favicon-maker, but the issue originates in favicon_maker.

My pngs are converted to dark (because the colorspace is changed). This results from the settings in creator.rb:

  if im_version
    print_image_magick_ancient_version_warning  if im_version < RECENT_IM_VERSION
    if im_version < COLORSPACE_MIN_IM_VERSION
      @colorspace_in   = "sRGB"
      @colorspace_out  = "RGB"
    else
      @colorspace_in   = "RGB"
      @colorspace_out  = "sRGB"
    end
  else
    print_image_magick_no_version_warning
    @colorspace_in   = "RGB"
    @colorspace_out  = "sRGB"
  end

I can fix this by setting both @colorspace_in and @colorspace_out to "sRGB". I believe the swap in colorspaces is not necessary any longer with the recent ImageMagick versions.

I am using:

According to the documentation middleman-core > 3.0 should pull favicon-maker 1.1.2. But my Gemfile.lock still reads (I do not understand this?):

  middleman-favicon-maker (3.5)
    favicon_maker (~> 1.0)
    middleman-core (>= 3.0.0)

So I had to make the change to the convert.rb from favicon_maker_-1.0. Thanks and cheers.

follmann commented 10 years ago

Hey, thanks for reporting this issue. I built this in as a hack to come around buggy behavior in ImageMagick. Since more and more people seem to have trouble because of this, I will revise the hack. Give me a couple days to get to it. Or beat me with a PR :wink:

karland commented 10 years ago

Sorry, can't beat you with a PR. I normally do not program in Ruby and do not really have a means to develop and test. So, I am looking forward to your fix. Concerning ImageMagick they have recently introduced a new change http://www.imagemagick.org/script/changelog.php see 2014-03-24 6.8.9-0 Cristy. I am not completely sure though what that exactly means...

Concerning -colorspace my feeling is probably to not set it at all, since there are too many options (see http://www.imagemagick.org/script/command-line-options.php#colorspace.

Probably an ideal extension to favicion_maker and to middleman-favicon-maker would be to provide for a free option string, that the user can set to his needs, such as

f.icons = {
  "favicon_template_hires.png" => [
    { option: "-colorspace sRGB -colorspace RGB" },
    { icon: "apple-touch-icon-152x152-precomposed.png" },
    { icon: "mstile-144x144", format: :png },
  ],

This would allow to use all options in colorspace in http://www.imagemagick.org/script/color-management.php and much more. Best and thanks.

Arcovion commented 10 years ago

I agree with not setting the colourspace, or provide an option like @karland said (but I don't know why you would want to change it).

I committed a change to suppress the warning, this hasn't made it into a release though yet and it probably shouldn't: https://github.com/follmann/favicon_maker/commit/acb71ae4bd6d564b164eccb1b8dccaa76169c970 I had no idea there were issues with colour changes until I read this.

follmann commented 10 years ago

the colorspace conversion has been removed from version v1.2.1 and you can pass an option string as second argument after the template filename. from "template.png", "-background grey" do

karland commented 10 years ago

@follmann Hey, that's great. Just installed it and it works smoothly. Many thanks!

@Arcovion It is well possible that you did not spot any differences between the template file and the generated .ico or .png files. This depends on how you generated the template files in the first place. Some graphic programs do not properly put or reference the colorspace that has been used within the file. In that case converters just make assumptions and issue a warning. I believe that could have been the case with your conversion. You can objectively measure a difference with a screen pipette. In case there is no difference, I assume you got lucky and your colorspace was not converted due to the fact that the original colorspace was not known to the converter. Best.

follmann commented 10 years ago

Cool, that these fixes worked out for you! Regarding those colorspace conversions I fear that color profiles in those files also play a role. This is another bag of agony, since every OS / browser combination seems to interpret them differently. Recently had issues with a screenshot I took. Madness.