Class: Assembly::Image
- Inherits:
-
ObjectFile
- Object
- ObjectFile
- Assembly::Image
- Defined in:
- lib/assembly/image.rb,
lib/assembly/image/jp2_creator.rb
Overview
The Image class contains methods to operate on an image.
Defined Under Namespace
Classes: Jp2Creator
Instance Method Summary collapse
-
#create_jp2(**params) ⇒ Assembly::Image
Create a JP2 file for the current image.
-
#has_profile? ⇒ Boolean
Does the image include an ICC profile?.
-
#height ⇒ integer
Image height in pixels.
-
#jp2_filename ⇒ string
Example: given original file of ‘/dir/path_to_file.tif’, gives ‘/dir/path_to_file.jp2’.
- #srgb? ⇒ Boolean
- #vips_image ⇒ Object
-
#width ⇒ integer
Image width in pixels.
Instance Method Details
#create_jp2(**params) ⇒ Assembly::Image
40 41 42 |
# File 'lib/assembly/image.rb', line 40 def create_jp2(**params) Jp2Creator.create(self, **params) end |
#has_profile? ⇒ Boolean
Does the image include an ICC profile?
56 57 58 |
# File 'lib/assembly/image.rb', line 56 def has_profile? vips_image.get_fields.include?('icc-profile-data') end |
#height ⇒ integer
Returns image height in pixels.
11 12 13 |
# File 'lib/assembly/image.rb', line 11 def height vips_image.height end |
#jp2_filename ⇒ string
Example: given original file of ‘/dir/path_to_file.tif’, gives ‘/dir/path_to_file.jp2’
22 23 24 25 |
# File 'lib/assembly/image.rb', line 22 def jp2_filename # path is a property on Assembly::ObjectFile File.extname(path).empty? ? "#{path}.jp2" : path.gsub(File.extname(path), '.jp2') end |
#srgb? ⇒ Boolean
51 52 53 |
# File 'lib/assembly/image.rb', line 51 def srgb? vips_image.interpretation == :srgb end |
#vips_image ⇒ Object
44 45 46 47 48 49 |
# File 'lib/assembly/image.rb', line 44 def vips_image # Disable cache. Otherwise, Vips gets confused by files with the same filename. Vips.cache_set_max_files(0) # autorot will only affect images that need rotation: https://www.libvips.org/API/current/libvips-conversion.html#vips-autorot @vips_image ||= Vips::Image.new_from_file(path).autorot end |
#width ⇒ integer
Returns image width in pixels.
16 17 18 |
# File 'lib/assembly/image.rb', line 16 def width vips_image.width end |