Skip to content
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

PEP 12: Update outdated image and comment formatting guidance #2365

Merged
merged 1 commit into from
Feb 27, 2022

Conversation

CAM-Gerlach
Copy link
Member

@CAM-Gerlach CAM-Gerlach commented Feb 26, 2022

Presently, PEP 12's guidance on including and describing images is thoroughly outdated and does not reflect the present reality, well-established best practices nor accessibility standards. This PR updates it to do so, by:

  • Removing the obsolete recommendation to use ASCII art to substitute for graphics for those reading the PEP in source text form (which as discussed Discourage using References? #2130 is no longer a common use case and does nothing to help accessibility) and instead recommends using descriptive alt text, which is more practical and aids both groups of users.
  • Explaining how to use the actual alt text option to the image directive, instead of a comment, to properly describe images, and updates the comment example accordingly
  • Provideing clearer suggestions on image formats to use, and cautioning against SVG for now due to SVGs fail to render on python.org #701

pep-0012.rst Outdated Show resolved Hide resolved
pep-0012.rst Outdated Show resolved Hide resolved
Comment on lines +578 to +579
Any browser-friendly graphics format is possible; PNG should be
preferred for graphics, JPEG for photos and GIF for animations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"PNG should be preferred for graphics, JPEG for photos" where does this guidance come from?

Equally, do we want to allow animated GIF images in a PEP?

Copy link
Member Author

@CAM-Gerlach CAM-Gerlach Feb 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"PNG should be preferred for graphics, JPEG for photos" where does this guidance come from?

For one thing, from the name of each format, following from their defined purpose and fundamental to how their respective compression strategies were designed.

The Joint Photographic Experts Group format was developed to use for, well, photographs, and its DCT-based compression handles their complex scenes, smooth gradients and high degrees of color variability well, but performs poorly on graphics, resulting in visibly inferior quality yet larger file size.

By contrast, Portable Network Graphics was explicitly created for, well, graphics, and uses a lossless DEFLATE + pre-filtering compression scheme plus color paletting to achieve excellent compression ratios on images with vector-style art, fewer discrete colors and defined shapes. but hugely balloons file size on photographs and similar relative to even a visually-lossless JPEG.

Equally, do we want to allow animated GIF images in a PEP?

I don't really have any opinion here; we can remove that if others do. I included it because it was mentioned in the original text (TIFF was elided, as it is not at all web-friendly and its use cases for this were better covered by JPEG and PNG).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. To an extent my challenge was do we really need to care about the differences between JPEG and PNG. It's rare enough though that we can take case by case if need be.

A

Copy link
Member Author

@CAM-Gerlach CAM-Gerlach Feb 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a long explanation, but I don't think it hurts to spend a mere few words briefly mentioning which format to use for what, when we're bringing up the formats anyway.

@CAM-Gerlach CAM-Gerlach force-pushed the pep-12-update-image-guidance branch from 7b2ad47 to 3b6556b Compare February 26, 2022 01:13
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good.

Any browser-friendly graphics format is possible; PNG should be
preferred for graphics, JPEG for photos and GIF for animations.
Currently, SVG must be avoided due to compatibility issues with the
PEP build system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope here, so just a note as accessibility is mentioned in the next paragraph, SVGs can be good for accessibility.

(Although it might require more work to create an accessible SVG than is usually put into images here.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, good point. One more reason for PEP 676, which should get them working, hopefully.

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

Successfully merging this pull request may close these issues.

5 participants