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

Compress images for PDF/EPUB #171

Closed
Daltz333 opened this issue Aug 21, 2019 · 4 comments
Closed

Compress images for PDF/EPUB #171

Daltz333 opened this issue Aug 21, 2019 · 4 comments

Comments

@Daltz333
Copy link
Member

Should be a way to do this without running a script.

@calcmogul
Copy link
Member

calcmogul commented Aug 21, 2019

I can only find rtd rst docs on including images, not compressing them. Compression can either be done to the images before they are included or after by ghostscript or something. Ghostscript at least takes the dpi of the output into account. It's worth noting that no matter what you do, the screenshots stored in png format are going to have compression artifacts. svg is preferred.

@Daltz333
Copy link
Member Author

After further review, this issue will inevitably conflict with #129. Compressing the images removes the ability to embed image meta data. There are also issues with being unable to determine which build was completed (HTML, latexpdf, epub), as well as Sphinx embedding fonts into the PDF.

I'll leave this issue open, but not a priority for a bit.

@Daltz333
Copy link
Member Author

We may be able to check metadata of the image to verify if it's labview embeddable or not.

@TheTripleV
Copy link
Member

# pip install pypng
import png

VI_CHUNK_TYPE = bytes("niVI", "utf-8")
def is_image_a_vi_snippet(image_path):
    with open(image_path, "rb") as image:
        reader = png.Reader(bytes=image.read())
    for chunk_type, chunk_data in reader.chunks():
        if chunk_type == VI_CHUNK_TYPE:
            return True
    return False

works for identifying if an image is a labview snippet.

From https://github.com/rcpacini/labview_snippet, vi snippets are stored in extra png chunks.

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

Successfully merging a pull request may close this issue.

4 participants