mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: fix orientation even for small JPEGs
This commit is contained in:
parent
c66b9dcdbd
commit
1c12dd529f
@ -46,6 +46,7 @@ class UploadCreator
|
|||||||
|
|
||||||
return @upload if is_still_too_big?
|
return @upload if is_still_too_big?
|
||||||
|
|
||||||
|
fix_orientation! if should_fix_orientation?
|
||||||
crop! if should_crop?
|
crop! if should_crop?
|
||||||
optimize! if should_optimize?
|
optimize! if should_optimize?
|
||||||
end
|
end
|
||||||
@ -186,6 +187,18 @@ class UploadCreator
|
|||||||
@file.rewind
|
@file.rewind
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def should_fix_orientation?
|
||||||
|
# orientation is between 1 and 8, 1 being the default
|
||||||
|
# cf. http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
|
||||||
|
@image_info.orientation.to_i > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def fix_orientation!
|
||||||
|
OptimizedImage.ensure_safe_paths!(@file.path)
|
||||||
|
Discourse::Utils.execute_command('convert', @file.path, '-auto-orient', @file.path)
|
||||||
|
extract_image_info!
|
||||||
|
end
|
||||||
|
|
||||||
def should_crop?
|
def should_crop?
|
||||||
TYPES_TO_CROP.include?(@opts[:type])
|
TYPES_TO_CROP.include?(@opts[:type])
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user