Skip to content

Option to create thumbnail without extension #150

Closed
@4javier

Description

@4javier

Expected behavior

Let the user choose if destination thumbnail name should got an extension or not.

Actual behavior

Extension for output get selected from original image format type if this one doesn't match with the passed extension.
(Why??? If it matches, it gets used. If it doesn't matches, it gets used anyway because they're identical. Why not use it directly, ignoring the supplied extension? But that's not the point here...)

Solution

On server, file extensions are quite useless. And they can be tricky to manipulate.
I was thinking of a flag NO_EXT to make the system not appending an extension at all to output file.
I forked your project and worked out a couple options:

  • Simpler dirty one:
    add a new const NO_EXT to Rename class, that strips out the extension from the file.
    Drawback is that all the work done by FileImageSink to appending it, would be wasted.
  • Correct heavy one:
    adding NO_EXT as Builder property (I got to study a bit this part of your code. It's kinda obscure to me...), and check for its value in FileImageSinkValue.write(BufferedImage) before all the other ones already present, and if true calling simply new File(destinationFile.getAbsolutePath())

The second one is my favorite approach.
Please, tell me what you think about that.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions