Giter Site home page Giter Site logo

Comments (22)

rikschennink avatar rikschennink commented on May 28, 2024 1

I've just published version 2.1.0 adding the imageTransformOutputQualityMode option.

Set it to 'optional' to only apply quality when resizing, cropping or changing file format.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024 1

Great, that works.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

The problem seems to be here:

// no transforms defined, we done!
if (quality === null && type === null && !crop && !transforms.length) {

where in transforms list there I have one transformation - resize - but since that is upscale=false, did not apply for my image, but is still in the list of transforms and the image is re-encoded

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Good one.

A transform can be defined but it can still have no effect on the output. For instance when the image size matches the required output size or there's no upscaling allowed and the image is smaller than the target size.

Will see if I can add this somehow.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

One way easy to do I thought would be just compare the imagedata after the transform worker returns the response. If the imagedata are unchanged, you can upload the original image. Problem I found is that the original image does not seem to be stored anywhere.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

That could work but I'm a bit worried comparing big ImageData objects might be too heavy on the CPU.

A way to know if a transform should be applied or if it has already been applied ( suppose the file is loaded from the server and has already been compressed / filtered / watermarked / resized / etc. ) would be more flexible and faster. With server files the server could return some additional information with the file ( as a custom header maybe ), then each transform ( currently it's only the crop and resize plugins, but I'm planning to add more ) could expose a boolean indicating whether it should be applied or not.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

That would definitely make more sense to do sort of verification on transforms before the image is loaded into canvas, since in case there are no transforms to be applied, that would not be necessary.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

@kasparek Just wanted to let you know that this is still on my radar but haven't gotten around to picking it up yet.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

It's tricky so I'm taking a bit of time to consider a good (future proof) approach, would hate to build something and have to make breaking changes later on.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Just wanted to let you know that it's still on my todo list, life has got in the way ;-)

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

I'm wondering if the new File Poster plugin combined with file mock information could help resolve this issue.

Add file mock information and poster image, with these settings FilePond does not load the actual file but creates a mock item. In this setup, the files don't have to be re-uploaded (and are therefore not transformed twice)?

const pond = FilePond.create({
    files: [
        {
            // the server file reference
            source: '12345',

            // set type to local to indicate an already uploaded file
            options: {
                type: 'local',

                // mock file information
                file: {
                    name: 'my-file.png',
                    size: 3001025,
                    type: 'image/png'
                },

                // url used by poster plugin
                metadata: {
                    poster: './url/to/my-file-thumb.png',
                }
            }
        }
    ]
});

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Alright, I assumed this only concerned files uploaded by the user in an earlier session.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Can you try with this alpha version of the image resize plugin?
https://github.com/pqina/filepond-plugin-image-resize/tree/1.2.0-alpha

It tests the original image size against the target image size and if they're the same, or if upscaling is disabled and the original image is smaller it wont set the resize info.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Okay, I’ll test this further when I get back from vacation in two weeks, had my fingers crossed that this was a quick fix to get it working.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

Just got back and ran some tests. I missed some edge cases. I've added reading of image orientation and the resulting width height corrections plus corrections for null values in the imageResizeTargetWidth and imageResizeTargetHeight properties. Just published version 2.0.1 of the image-resize plugin which contains these fixes, please let me know if this solves the problem on your side.

I've also published version 1.1.2 of the image-transform plugin, it's not related to this problem but it does fix another EXIF orientation bug so it's best to update that plugin as well.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

Great, will test and let you know.

from filepond-plugin-image-transform.

kasparek avatar kasparek commented on May 28, 2024

So, I'm not sure if I'm doing something wrong, but the image when smaller than target size and upscale is false, is correctly not upscaled (is uploaded with same dimensions), but still re-encoded (the filesize is different). This is my configuration for filepond:
FilePond.create(
input,
{
imageTransformOutputQuality: 60,
imagePreviewHeight: 270,
imageResizeUpscale: false,
imageResizeTargetWidth: 2190,
imageResizeTargetHeight: 2190,
imageResizeMode: 'contain'
}
);

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 28, 2024

It gets re-encoded because the output quality parameter is set.

I'm going to add a bool that allows you to configure it to only apply quality to images when they require a transform.

from filepond-plugin-image-transform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.