Skip to content

Commit

Permalink
Don’t change the extension if the format is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jun 16, 2024
1 parent 91c2753 commit a0d624c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ext/kemal_gphoto2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def send_file(env, file : GPhoto2::CameraFile, *, format : ImageOutputFormat?, w
end
format ||= ImageOutputFormat::JPEG

if format == path_format && !(width || height)
is_same_format = (format == path_format)
if is_same_format && !(width || height)
send_file env, file,
disposition: disposition
return
Expand Down Expand Up @@ -151,7 +152,10 @@ def send_file(env, file : GPhoto2::CameraFile, *, format : ImageOutputFormat?, w
str << "-w#{width}" if width
str << "-h#{height}" if height
str <<
if path.extension.chars.select!(&.letter?).all?(&.uppercase?)
case
when is_same_format
path.extension
when path.extension.chars.select!(&.letter?).all?(&.uppercase?)
format.extension.upcase
else
format.extension
Expand Down

0 comments on commit a0d624c

Please sign in to comment.