docs: add remaining docs for classes in app/logical.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# A MediaFile for a JPEG, PNG, or GIF file. Uses libvips for resizing images.
|
||||
#
|
||||
# @see https://github.com/libvips/ruby-vips
|
||||
# @see https://libvips.github.io/libvips/API/current
|
||||
class MediaFile::Image < MediaFile
|
||||
# Taken from ArgyllCMS 2.0.0 (see also: https://ninedegreesbelow.com/photography/srgb-profile-comparison.html)
|
||||
SRGB_PROFILE = "#{Rails.root}/config/sRGB.icm"
|
||||
@@ -31,8 +35,8 @@ class MediaFile::Image < MediaFile
|
||||
is_animated_gif? || is_animated_png?
|
||||
end
|
||||
|
||||
# https://github.com/jcupitt/libvips/wiki/HOWTO----Image-shrinking
|
||||
# http://jcupitt.github.io/libvips/API/current/Using-vipsthumbnail.md.html
|
||||
# @see https://github.com/jcupitt/libvips/wiki/HOWTO----Image-shrinking
|
||||
# @see http://jcupitt.github.io/libvips/API/current/Using-vipsthumbnail.md.html
|
||||
def preview(width, height)
|
||||
output_file = Tempfile.new(["image-preview", ".jpg"])
|
||||
resized_image = image.thumbnail_image(width, height: height, **THUMBNAIL_OPTIONS)
|
||||
@@ -62,6 +66,7 @@ class MediaFile::Image < MediaFile
|
||||
file_ext == :png && APNGInspector.new(file.path).inspect!.animated?
|
||||
end
|
||||
|
||||
# @return [Vips::Image] the Vips image object for the file
|
||||
def image
|
||||
Vips::Image.new_from_file(file.path, fail: true)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
# A MediaFile for a Pixiv ugoira file.
|
||||
#
|
||||
# A Pixiv ugoira is an animation format that consists of a zip file containing
|
||||
# JPEG or PNG images, one per frame, plus a JSON object containing the
|
||||
# inter-frame delay timings. Each frame can have a different delay, therefore
|
||||
# ugoiras can have a variable framerate. The frame data isn't stored inside the
|
||||
# zip file, so it must be passed around separately.
|
||||
class MediaFile::Ugoira < MediaFile
|
||||
class Error < StandardError; end
|
||||
attr_reader :frame_data
|
||||
@@ -25,6 +32,7 @@ class MediaFile::Ugoira < MediaFile
|
||||
preview_frame.crop(width, height)
|
||||
end
|
||||
|
||||
# Convert a ugoira to a webm.
|
||||
# XXX should take width and height and resize image
|
||||
def convert
|
||||
raise NotImplementedError, "can't convert ugoira to webm: ffmpeg or mkvmerge not installed" unless self.class.videos_enabled?
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# A MediaFile for a webm or mp4 video. Uses ffmpeg to generate preview
|
||||
# thumbnails.
|
||||
#
|
||||
# @see https://github.com/streamio/streamio-ffmpeg
|
||||
class MediaFile::Video < MediaFile
|
||||
def dimensions
|
||||
[video.width, video.height]
|
||||
|
||||
Reference in New Issue
Block a user