You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: upload_creator.rb
    path of file: ./repos/discourse/lib
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require "fastimage"

class Uplo
    
  def convert_to_jpeg!
    return if @opts[:for_site_setting]
    return if filesize < MIN_CONVERT_TO_JPEG_BYTES_SAVED

    jpeg_tempfile = Tempfile.new(%w[image .jpg])

    from = @file.path
    to = jpeg_tempfile.path

    OptimizedImage.ensure_safe_paths!(from, to)

    from = OptimizedImage.prepend_decoder!(from, nil, filename: "image.#{@image_info.type}")
    to = OptimizedImage.prepend_decoder!(to)

    opts = {}
    desired_quality = [
      SiteSetting.png_to_jpg_quality,
      SiteSetting.recompress_original_jpg_quality,
    ].compact.min
    target_quality = @upload.target_image_quality(from, desired_quality)
    opts = { quality: target_quality } if target_quality

    begin
      execute_convert(from, to, opts)
    rescue StandardError
      # retry with debugging enabled
      execute_convert(from, to, opts.merge(debug: true))
    end