Patch #43932 ยป Add-HEIC-HEIF-image-support.patch
| app/models/attachment.rb | ||
|---|---|---|
|
end
|
||
|
def image?
|
||
|
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp)$/i)
|
||
|
!!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp|heic|heif)$/i)
|
||
|
end
|
||
|
def thumbnailable?
|
||
|
-- a/app/helpers/application_helper.rb
|
||
|
++ b/app/helpers/application_helper.rb
|
||
| ... | ... | |
|
if attachments.present?
|
||
|
title_and_alt_re = /\s+(title|alt)="([^"]*)"/i
|
||
|
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp))"([^>]*)/i) do |m|
|
||
|
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp|heic|heif))"([^>]*)/i) do |m|
|
||
|
filename, ext, other_attrs = $1, $2, $3
|
||
|
# search for the picture in attachments
|
||
|
-- a/lib/redmine/thumbnail.rb
|
||
|
++ b/lib/redmine/thumbnail.rb
|
||
| ... | ... | |
|
('gswin64c' if Redmine::Platform.mswin?) ||
|
||
|
'gs'
|
||
|
).freeze
|
||
|
ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png image/webp application/pdf)
|
||
|
ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png image/webp image/heic image/heif application/pdf)
|
||
|
# Generates a thumbnail for the source image to target
|
||
|
# TODO: Remove the deprecated _is_pdf parameter in Redmine 7.0
|
||
| ... | ... | |
|
return nil unless valid_pdf_magic?(source)
|
||
|
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}"
|
||
|
elsif mime_type == 'image/heic' || mime_type == 'image/heif'
|
||
|
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote "jpg:#{target}"}"
|
||
|
else
|
||
|
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}"
|
||
|
end
|
||
|
-- a/app/controllers/attachments_controller.rb
|
||
|
++ b/app/controllers/attachments_controller.rb
|
||
| ... | ... | |
|
if is_thumb && content_type == "application/pdf"
|
||
|
# PDF previews are stored in PNG format
|
||
|
content_type = "image/png"
|
||
|
elsif is_thumb && (content_type == "image/heic" || content_type == "image/heif")
|
||
|
# HEIC/HEIF previews are stored in JPEG format
|
||
|
content_type = "image/jpeg"
|
||
|
end
|
||
|
content_type
|
||