Prevent stripping color profiles from JPEGs

This commit is contained in:
Marek Lipka 2019-09-04 20:43:17 +02:00 committed by noellabo
parent 4bb8969b69
commit 145c0ccd2a
5 changed files with 6 additions and 6 deletions

View file

@ -18,7 +18,7 @@ module AccountAvatar
included do
# Avatar upload
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '+profile exif' }, processors: [:lazy_thumbnail]
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
validates_attachment_size :avatar, less_than: LIMIT
remotable_attachment :avatar, LIMIT, suppress_errors: false

View file

@ -19,7 +19,7 @@ module AccountHeader
included do
# Header upload
has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '+profile exif' }, processors: [:lazy_thumbnail]
validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
validates_attachment_size :header, less_than: LIMIT
remotable_attachment :header, LIMIT, suppress_errors: false

View file

@ -34,7 +34,7 @@ class CustomEmoji < ApplicationRecord
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } }
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile exif' } }
before_validation :downcase_domain

View file

@ -147,7 +147,7 @@ class MediaAttachment < ApplicationRecord
}.freeze
GLOBAL_CONVERT_OPTIONS = {
all: '-quality 90 -strip +set modify-date +set create-date',
all: '-quality 90 +profile exif +set modify-date +set create-date',
}.freeze
IMAGE_LIMIT = 10.megabytes

View file

@ -41,7 +41,7 @@ class PreviewCard < ApplicationRecord
has_and_belongs_to_many :statuses
has_attached_file :image, processors: [:thumbnail, :blurhash_transcoder], styles: ->(f) { image_styles(f) }, convert_options: { all: '-quality 80 -strip' }
has_attached_file :image, processors: [:thumbnail, :blurhash_transcoder], styles: ->(f) { image_styles(f) }, convert_options: { all: '-quality 80 +profile exif' }
include Attachmentable
@ -78,7 +78,7 @@ class PreviewCard < ApplicationRecord
original: {
geometry: '400x400>',
file_geometry_parser: FastGeometryParser,
convert_options: '-coalesce -strip',
convert_options: '-coalesce +profile exif',
blurhash: BLURHASH_OPTIONS,
},
}