Some imagemagick-versions (I tested Ubuntu 22.04 and debian bullseye) always loose exif data when converting from jpg to webp. So this made our CI fail now, but even if it wasn't failing before, some pods always had and have versions which might loose the information anyway. So having a setting to keep exif information is kinda pointless, if we can't guarantee that the information isn't lost. Also, diaspora isn't a photo sharing platform and we don't display exif information anywhere, so I think we should just always strip exif data (which was already the default before), as we don't need them.
57 lines
1.2 KiB
Ruby
57 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
|
# licensed under the Affero General Public License version 3 or later. See
|
|
# the COPYRIGHT file.
|
|
|
|
class UnprocessedImage < CarrierWave::Uploader::Base
|
|
include CarrierWave::MiniMagick
|
|
|
|
def store_dir
|
|
"uploads/images"
|
|
end
|
|
|
|
def extension_allowlist
|
|
%w[jpg jpeg png gif webp]
|
|
end
|
|
|
|
def filename
|
|
model.random_string + extension if @filename
|
|
end
|
|
|
|
def extension
|
|
needs_converting? ? ".webp" : File.extname(@filename)
|
|
end
|
|
|
|
def needs_converting?
|
|
extname = File.extname(@filename)
|
|
%w[.webp .gif].exclude?(extname) && !model.keep_original_format
|
|
end
|
|
|
|
process :basic_process
|
|
|
|
def basic_process
|
|
manipulate! do |img|
|
|
img.combine_options do |i|
|
|
i.auto_orient
|
|
i.strip
|
|
end
|
|
|
|
img = yield(img) if block_given?
|
|
|
|
img.format("webp") if needs_converting?
|
|
img
|
|
end
|
|
end
|
|
|
|
version :thumb_small
|
|
version :thumb_medium
|
|
version :thumb_large
|
|
version :scaled_full do
|
|
process :get_version_dimensions
|
|
end
|
|
|
|
def get_version_dimensions
|
|
model.width, model.height = `identify -format "%wx%h " #{file.path}`.split(/x/)
|
|
end
|
|
end
|