Class: Morandi::ProfiledPixbuf

Inherits:
GdkPixbuf::Pixbuf show all
Defined in:
lib/morandi/profiled_pixbuf.rb

Overview

ProfiledPixbuf is a descendent of GdkPixbuf::Pixbuf with ICC support. It attempts to load an image using jpegicc/littlecms to ensure that it is sRGB. NOTE: pixbuf supports colour profiles, but it requires an explicit icc-profile option to embed it when saving file

Instance Method Summary collapse

Methods inherited from GdkPixbuf::Pixbuf

#scale_max, #to_cairo_image_surface

Constructor Details

#initialize(path, _local_options, max_size_px = nil) ⇒ ProfiledPixbuf

Returns a new instance of ProfiledPixbuf.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/morandi/profiled_pixbuf.rb', line 11

def initialize(path, _local_options, max_size_px = nil)
  srgb_converted_file_path = srgb_path(path)
  path = srgb_converted_file_path || path

  if max_size_px
    super(file: path, width: max_size_px, height: max_size_px)
  else
    super(file: path)
  end
ensure
  FileUtils.rm_f(srgb_converted_file_path) if srgb_converted_file_path
end