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

Scale images in PDF relative to its original size #1933

Closed
tedour opened this issue May 21, 2021 · 3 comments
Closed

Scale images in PDF relative to its original size #1933

tedour opened this issue May 21, 2021 · 3 comments

Comments

@tedour
Copy link

tedour commented May 21, 2021

Now all options to scale images are relative to the width of the content area (https://asciidoctor.org/docs/asciidoctor-pdf/#image-scaling).
I'd like to have an option to scale the image based of it's original size (1300px => 100% of the width, 650px => 50% of the width for example, 325px => 25%, etc)
Prawn seem to be able to do it (https://prawnpdf.org/docs/0.11.1/Prawn/Images.html) with scale argument.

@mojavelinux mojavelinux changed the title Scale images in PDF relative to it's original size Scale images in PDF relative to its original size May 21, 2021
@mojavelinux mojavelinux added this to the v2.0.x milestone May 21, 2021
@mojavelinux mojavelinux self-assigned this May 21, 2021
@mojavelinux
Copy link
Member

This would entail implementing support for the scale attribute in this converter.

@cod3licious
Copy link

Somewhat related to this, I was wondering, if it is possible to globally scale all images relative to their defined width as well.

For the html version, I've set a dimensionless width argument for all my images (e.g. width=340), which looks good in the html version, but feels a bit too large in the PDF.

It would be great if something like image-scale: 80% defined in the theme would automatically convert width=340 to width=0.8 * 340 and in case width is not set for an image, it could act on the original size of the image instead, thereby (I think) covering both use cases.

One important thing here is that this should only act on actual images, not mathematical formulas inserted as quasi-block images (I've noticed that setting image: width: 80% in the theme file didn't do anything for my images which already had a width attributed, but suddenly all my non-inline equations were really big, since apparently they are treated as normal images).

@graphitefriction graphitefriction modified the milestones: v2.0.x, v2.1.x May 16, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 19, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 19, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 20, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 4, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 5, 2022
@mojavelinux
Copy link
Member

I implemented this by adding support for the scale attribute (e.g., scale=0.5) as well as the iw units on the pdfwidth attribute (pdfwidth=0.5iw).

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

No branches or pull requests

4 participants