Skip to content

Upstream image_processing: route the saver by an explicit format argument, not the destination extension #4

Closed

Description

@flavorjones

What we're trying to optimize

The cell's transform operations write their output to a staged scratch path, and scratch names carry no extension. ImageProcessing picks its saver from the destination path's extension, so Transforming#perform must encode to a suffixed sibling (Output#path(extension:)) and rename it into place (Output#adopt). That is a naming hoop and a rename syscall per transform, done only to smuggle the output format to the saver through the filename.

What happens today

pipeline.call(destination:) hands the path to the toolchain, and the toolchain picks the saver from the path's extension — libvips dispatches write_to_file on the suffix, and magick infers the output format from the output filename. convert(format) only names the tempfile extension when ImageProcessing creates its own tempfile. With an explicit destination, the filename wins.

Proposed upstream change

An explicit format/extension argument on call that defaults to the destination's file name when absent. It must be additive: some users rely on the destination extension winning over convert. The change is clean on both backends, inside ImageProcessing where its saver defaults already live:

  • vips: ruby-vips has write_to_target, which takes the format hint as an argument separate from the filename. ImageProcessing can route through it and keep its own quality, strip, and format defaults.
  • MiniMagick: ImageMagick accepts an explicit output format as a PNG:/path prefix on the output filename. One string change.

Payoff

For hotcell: it removes the suffixed-sibling dance and one rename on the transform path. That is modest, since Output#adopt stays either way — pdftoppm names its own output and still needs it. The general case is stronger: anyone writing to an extensionless path (content-addressed names, descriptor-backed paths) hits this wart.

Actions

  • File an issue on janko/image_processing describing the use case, then follow with a pull request once the maintainer reacts.
  • Adopt whatever solution is merged upstream (if any)

Activity

  1. flavorjones commented on Sep 28, 2026

    @flavorjones
    MemberAuthor

    Opened upstream as janko/image_processing#149, with an implementation in janko/image_processing#150.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions