-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sizeByPixelDensity was deprecated because of a bug #23376
Comments
Yes, it can work, but there is more than few examples of it not working correctly.
We used That said - this might have changed in more recent |
Ok, so if you check https://github.com/pieh/sharp-density - it has one of the images that was causing problems referenced in the #12743 - running Just in case this is exactly this image https://github.com/eggheadio/how-to-egghead/blob/3a54c95c4fd1b9a779998732bac1f6713bf36d34/content/instructor/screencasting/audio-equipment/images/audio-setup/full-set-up.jpg and it wasn't tampered with by us ... There might be nicer way to do this than just disabling entire option, but the problem with this was that it was very unreliable and people couldn't see those issues coming (there was no errors or anything like that), so potential for broken deploys was too great and we decided that this option is just not safe |
Forgot to mention - above small test repository is using latest |
Considering that you are carrying on with disabling this further: What is the Gatsby way of placing an image that is smaller than the content width while keeping it sharp for retina screens? So far it looks like we are only removing capabilities that at least work in some scenarios while not providing alternatives. An alternative to disabling this completely could be to have some recommendations in this docs, accompanied by warnings/ignore rules for densities that do not seem to make sense. Possibly complemented by whitelisting of supported image resolutions. |
Yeah, would've been nice for it to work if you know what you are doing and setting pixel density correctly. |
The docs PR was mostly to correctly reflect current state of things - please don't read too much into it "carrying on with disabling" I found few original issues / pull requests about this:
The interesting findings in #1509 to me was that GitHub renderer only special cases 144DPI pretty much, and this (that + maybe few other whitelisted DPI) could be the solution here (so restore handling of the option - but only really do calculation if The thing about documentation is that it's great when users learning how to do things or need a reference, but it's not so great when troubleshooting issues. What will happen if we would just restore Does above make sense? |
Also the issue you created ( #1982 ) as "Summary of" #1509 explicetely say about 144DPI and nothing else, so it seems at least on this part we would be on same page? Just additional thought - if we would be to re-add this - I would suggest changing the name of the option to signify a bit different behaviour (the old option deprecation message would be changed to lookup docs for the new one) |
Sounds like a fair suggestion @pieh! Thank you for your investigation! 👍 |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
I understand we've had a regression with this issue. I'd like to offer my two cents as DPI is definitely a "real" aspect when it comes to some applications. In the web world this isn't much of an issue. We have native desktop applications that render images and when provided wrong DPI images they render improperly. Also for printing purposes there are also inconsistencies if a JPEG or PNG file is not provided proper DPI. It's hard to get to the bottom of the property nomenclature as applications and APIs all seem to reference them differently. Anyways, as far as Sharp, with the lack of support for density I've been using a base image with the DPI of my requirements and creating a composite with that image as the base. I have quite a few base images with varying DPI. I fetch the one I need and composite it with the transient image. The resulting output image appears to take the DPI of the base image in the composite. |
Description
Gatsby v2 is reporting that the
sizeByPixelDensity
option is deprecated (spamming ourgatsby develop
mode quite heavily in fact). Specifically gatsby-plugin-sharp documents this as a deprecated config option, but gatsby-remark-images doesn't.Also the deprecation reason in
gatsby-plugin-sharp
is wrong. This feature does work fine for JPEG and PNG files in Gatsby v1, but it is broken in Gatsby v2. We are in fact using this extensively for https://docs.instana.io. Looking through some tickets that were opened around this topic, it seems this is the result of a lot of confusion. Most specifically #12743 as a result of which 4131a09 was made. Especially the deprecation commit removes a test which proves that it can work.As far as I can tell (as the original author of this feature as part of Gatsby v1):
a) The feature works as proven by the test and our own heavy usage in Gatsby v1.
b) The feature was broken as part of Gatsby v2.
b) There is demand for this feature as shown by at least one more bug ticket asking for such a capability.
c) Pixel density is not a simple topic and there is a lot of confusion around this. Possibly needing more examples? Additional test cases might have helped as well to avoid the breakage with Gatsby v2.
Steps to reproduce
Add the following plugin configuration:
Use an image with resolution
144
. Ensure that it renders at half the actual horizontal pixels.Expected result
sizeByPixelDensity
should not be deprecated. Instead the bug introduced with Gatsby v2 should be fixed.The following screenshot shows what it looks like with Gatsby v1 (works as intended). Note the size of the original picture in MacOS' image viewer. Both browser and image viewer are showing the image at 100% size.
Actual result
A bug was introduced with Gatsby v2, breaking the feature, causing a lot of confusion which ended with the deprecation of
sizeByPixelDensity
. The following screenshot shows what it looks like with Gatsby v2 (sorry, cannot link to the deployed version because we aren't ready to ship this yet). Note the size of the original picture in MacOS' image viewer. Both browser and image viewer are showing the image at 100% size.Environment
The text was updated successfully, but these errors were encountered: