uploads: autotag animated_gif/png during upload.

Move animated_gif / animated_png autotagging to take place during
uploading, instead of during tag editing. We can't generally assume the
file will be present on the local filesystem after uploading.
This commit is contained in:
evazion
2018-03-18 11:55:24 -05:00
parent 2286ccfca8
commit 60dcfbfbdd
3 changed files with 23 additions and 34 deletions

View File

@@ -255,24 +255,6 @@ class Post < ApplicationRecord
file_ext =~ /jpg|jpeg|gif|png/i
end
def is_animated_gif?
if file_ext =~ /gif/i && File.exists?(file_path)
return Magick::Image.ping(file_path).length > 1
else
return false
end
end
def is_animated_png?
if file_ext =~ /png/i && File.exists?(file_path)
apng = APNGInspector.new(file_path)
apng.inspect!
return apng.animated?
else
return false
end
end
def is_flash?
file_ext =~ /swf/i
end
@@ -765,7 +747,6 @@ class Post < ApplicationRecord
return tags if !Danbooru.config.enable_dimension_autotagging
tags -= %w(incredibly_absurdres absurdres highres lowres huge_filesize flash webm mp4)
tags -= %w(animated_gif animated_png) if new_record?
if has_dimensions?
if image_width >= 10_000 || image_height >= 10_000
@@ -794,14 +775,6 @@ class Post < ApplicationRecord
tags << "huge_filesize"
end
if is_animated_gif?
tags << "animated_gif"
end
if is_animated_png?
tags << "animated_png"
end
if is_flash?
tags << "flash"
end