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

Add image scaling attributes to block image in DocBook backend #763

Closed
mojavelinux opened this issue Nov 1, 2013 · 7 comments
Closed

Add image scaling attributes to block image in DocBook backend #763

mojavelinux opened this issue Nov 1, 2013 · 7 comments
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

Add the following image scaling attributes to the block image output in the DocBook backend:

  • scaled
  • scaledwidth (assumed to be a %)

When the scaledwidth attribute is specified, the scalefit="1" attribute should be added to the <imagedata> tag as well.

Example:

image::sunset.jpg[Sunset, scaledwidth="75%"]

Output:

<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="sunset.jpg" width="75%" scalefit="1"/>
</imageobject>
<textobject><phrase>Sunset</phrase></textobject>
</mediaobject>
</informalfigure>

Note that in Python AsciiDoc, it's necessary to define the alt attribute explicitly when any other attribute is present. For example:

image::sunset.jpg[alt="Sunset", scaledwidth="75%"]
@ghost ghost assigned mojavelinux Nov 1, 2013
@mojavelinux
Copy link
Member Author

Open Question: Should we assume the scaledwidth value is a percentage? Or should we leave it open for the writer to set the units?

@lordofthejars
Copy link
Member

I think that % should be the default and it is a good practice to use
percentatges, but supporting other units Can be useful for some people, if
it is easy I think we should support it

El divendres 1 de novembre de 2013, Dan Allen ha escrit:

Open Question: Should we assume the scaledwidth value is a percentage?
Or should we leave it open for the writer to set the units?


Reply to this email directly or view it on GitHubhttps://github.com//issues/763#issuecomment-27540066
.

Enviat amb Gmail Mobile

@mojavelinux
Copy link
Member Author

Super. I added that feature.

mojavelinux added a commit that referenced this issue Nov 2, 2013
resolves #763 added scaling & align attributes to block image in DocBook backend
@nerk
Copy link
Member

nerk commented Feb 19, 2015

There still seems to be a compatibility issue with original asciidoc. If I remember correctly, original asciidoc allows to use both attributes, width and scaledwidth at the same time. width will only apply to HTML output, scaledwidth to docbook output.

I am able to write

image::someimage.png[width="500", scaledwidth="70%"]

This is different in Asciidoctor. scaledwidth only applies to docbook output, but width applies to both, HTML and docbook. This causes such images not being scaled properly in generated PDF.

Apparently, the backend sets contentwidth and contentheight attributes based on width and height parameters.

As a workaround, I could use some conditional macros, but I am just wondering if this is how it should be.

@mojavelinux
Copy link
Member Author

I'm pretty sure Asciidoctor and AsciiDoc Python have the same behavior. However, it's possible that in both cases it's incorrect.

You can see that AsciiDoc Python uses width and height if present, even if scaledwidth is present.

https://github.com/asciidoc/asciidoc/blob/master/docbook45.conf#L88

If you think a change is warranted, let's move forward with a separate issue that proposes the change.

(not that this may be an Asciidoctor PDF issue because I know that scaling isn't working quite as we expect there).

@nerk
Copy link
Member

nerk commented Apr 1, 2015

Yes, you are correct! I compared the docbook outputs asciidoc and asciidoctor and they are the same. Must have been something else, maybe related to #1059 and the FOP backend I am using.

Scaling to different media is quite a bit of PITA...

@mojavelinux
Copy link
Member Author

Scaling to different media is quite a bit of PITA...

I agree. And PDF doesn't make reasoning about it easy in my experience.

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

3 participants