Created
October 23, 2022 22:06
-
-
Save michalkorzawski/342e0c263166a0bb10004bbcf034b86f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/image_converter.rb | |
class ImageConverter | |
def initialize(tempfile:, width: nil, height: nil, type: 'jpg') | |
@tempfile = tempfile | |
@width = width | |
@height = height | |
@type = type | |
end | |
def call | |
ImageProcessing::MiniMagick.source(@tempfile) | |
.resize_to_limit(@width, @height) | |
.convert(@type) | |
.call | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment