GithubHelp home page GithubHelp logo

Comments (9)

JonasKruckenberg avatar JonasKruckenberg commented on July 23, 2024 1

Fixed and published please upgrade to [email protected]

from imagetools.

JonasKruckenberg avatar JonasKruckenberg commented on July 23, 2024

This is really bad 😟
This only appears during development right? So when you do yarn build all the right images get generated?

from imagetools.

jpoep avatar jpoep commented on July 23, 2024

Oh, I haven't even thought about testing that. And yeah, you're right, it works in production, so it isn't that terrible after all.

from imagetools.

bronze avatar bronze commented on July 23, 2024

This only appears during development right? So when you do yarn build all the right images get generated?

oh god dammit... I've been cracking my head trying to figure this one out...
yeah.... can confirm, at least on my testing, the switch happens alright once deployed, just during dev that it only shows the last size

from imagetools.

jugglingcats avatar jugglingcats commented on July 23, 2024

@JonasKruckenberg I just hit this one too. The problem seems to be in the vite plugin and the middleware added in configureServer. To debug I looked for use of generatedImages and added the following:

// before generatedImage.set
console.log("set image", id, imagetoolsCore.getMetadata(image, 'width'))

// after generatedImage.get (in middleware)
console.log("get image", id, imagetoolsCore.getMetadata(image, 'width'))

In the logs...

set image 6269821afe096f8aea2f2ba455cddea6fa0b734a 500
set image cb68b63cfb6eadc77da1ba1b4f5866595fe545e2 700
get image 6269821afe096f8aea2f2ba455cddea6fa0b734a 700 <--- ooops!
get image cb68b63cfb6eadc77da1ba1b4f5866595fe545e2 700

Something is being reused somewhere...? I then modified this line:

//             generatedImages.set(id, image); // from
                generatedImages.set(id, image.clone()); // to

New log output:

set image 6269821afe096f8aea2f2ba455cddea6fa0b734a 500
set image cb68b63cfb6eadc77da1ba1b4f5866595fe545e2 700
get image 6269821afe096f8aea2f2ba455cddea6fa0b734a undefined
get image cb68b63cfb6eadc77da1ba1b4f5866595fe545e2 undefined

... and images in the site are the correct size πŸŽ‰.

from imagetools.

jugglingcats avatar jugglingcats commented on July 23, 2024

I guess it is because of this line:

            const img = imagetoolsCore.loadImage(decodeURIComponent(srcURL.pathname));

... this img is passed to imagetoolsCore.applyTransforms and returned, so same image is put in the Set.

from imagetools.

JonasKruckenberg avatar JonasKruckenberg commented on July 23, 2024

Good catch! The sharp instance is mutable indeed and so will be changed by subsequent iterations, cloning should solve this!

from imagetools.

suamai avatar suamai commented on July 23, 2024

Hey, this issue seems to have been fixed by the PR #218 , but was rolled back by this commit f6cec96 .

Is there a reason for that?

from imagetools.

JonasKruckenberg avatar JonasKruckenberg commented on July 23, 2024

Oups, must have been lost in the merges somehow!

from imagetools.

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.