Open Shrinks99 opened 3 years ago
Yes, I think #6946 was the last change to how we output images in ICML... and I remember it involved a lot of trial and error :P
Back when I implemented images originally I didn't think there would be much use for images inside the text beyond tiny inline-images. And people would generally place the images in InDesign instead of having them part of the markdown file... but maybe that was a simplistic assumption...
The first step would be to find out exactly what the XML should look like... can we simply wrap the image in an element and keep everything inside as it?
I've come up with some settings that would work reasonably well as generalized defaults for an Image
graphic style. Unfortunately InDesign doesn't seem to let users set the width by percentage of text box so I tried to assume a reasonable default of 12p0x24p0 but this can definitely be up for debate. The image will expand to fill the height and width of the container while keeping its proportions and aligning itself to the right. Further modifications can be made to all images in InDesign by editing the Image
graphic style, if users wish to set absolute width & height values they can do so in Pandoc with the method that currently works fine.
Here's the object style I made for images that InDesign spits out when I export this document to an ICML, it's probably longer and more aggressively defined than it needs to be...
<ObjectStyle Self="ObjectStyle/Image" EnableTransformAttributes="true" TopLeftCornerOption="None" TopRightCornerOption="None" BottomLeftCornerOption="None" BottomRightCornerOption="None" TopLeftCornerRadius="12" TopRightCornerRadius="12" BottomLeftCornerRadius="12" BottomRightCornerRadius="12" EmitCss="true" IncludeClass="true" EnableTextFrameAutoSizingOptions="false" ExtendedKeyboardShortcut="0 0 0" EnableTextFrameColumnRuleOptions="false" EnableExportTagging="false" EnableObjectExportAltTextOptions="true" EnableObjectExportTaggedPdfOptions="true" EnableObjectExportEpubOptions="true" Name="Image" AppliedParagraphStyle="ParagraphStyle/$ID/NormalParagraphStyle" ApplyNextParagraphStyle="false" EnableFill="false" EnableStroke="false" EnableParagraphStyle="false" EnableTextFrameGeneralOptions="false" EnableTextFrameBaselineOptions="false" EnableStoryOptions="false" EnableTextWrapAndOthers="false" EnableAnchoredObjectOptions="false" CornerRadius="12" FillColor="Swatch/None" FillTint="-1" StrokeWeight="0" MiterLimit="4" EndCap="ButtEndCap" EndJoin="MiterEndJoin" StrokeType="StrokeStyle/$ID/Solid" LeftLineEnd="None" RightLineEnd="None" StrokeColor="Swatch/None" StrokeTint="-1" GapColor="Swatch/None" GapTint="-1" StrokeAlignment="CenterAlignment" Nonprinting="false" GradientFillAngle="0" GradientStrokeAngle="0" AppliedNamedGrid="n" KeyboardShortcut="0 0" EnableFrameFittingOptions="true" CornerOption="None" EnableStrokeAndCornerOptions="false" ArrowHeadAlignment="InsidePath" LeftArrowHeadScale="100" RightArrowHeadScale="100" EnableTextFrameFootnoteOptions="false">
Example file: Image Example.zip
Unfortunately InDesign doesn't seem to let users set the width by percentage of text box so I tried to assume a reasonable default of 12p0x24p0
that's unfortunate indeed... maybe @lrosenthol has some input?
Is there any progress on this matter? I have an otherwise working workflow from latex to icml via pandoc but at the moment, this involves omitting the images in latex because they are not displayed properly in Indesign.
I would also be curious to know if this feature has progressed since the last time. I find that having linked images from markdown converted to images in a styled image frame in ICML would be extremely convenient, since the original markdown document would contain everything, but the final styling.
There hasn't been any progress (or it would be reported here). I don't know enough about ICML to be confident making changes myself. @mb21 what do you think of the proposal above? Is it something that could be made into a PR?
Yes, seems like generally a good idea. As always with ICML output, implementing it just requires a lot of trial-and-error to see how the output actually looks and behaves in InCopy and when placed in InDesign. If somebody is willing to put in that work, go for it!
I can test it with InDesign CS6 (and Affinity Publisher), but not InCopy. If there is some new code, I can do some of the tests.
Well, I could probably update the code, but I'd need someone to spell out explicitly all the changes needed to the output and/or templates.
I'd need someone to spell out explicitly all the changes needed to the output and/or templates.
I don't know if the attached .icml file exported from InDesign CS6 can be of any help. All it contains are two paragraph styles (Body, Image) and an object style (My Image Object Style), this latter applied to the image in the Image-styled paragraph.
span and div styles are already reserved to character and paragraph styles. I frankly don't know how to define object styles in markdown. Are there, maybe, other examples on how to define frame styles? Object styles shouldn't be different from frame styles. image-object-style-test.icml.zip
What would be most useful to me would be a diff between this and the current pandoc output.
Let's see if there is something useful here. I generated a pandoc-tinged multimarkdown document from Scrivener, and then converted it to .icml via pandoc 3.1 for Mac. It doesn't contain custom styles, since I still don't know how to do it automatically in Scrivener. It doesn't contain custom object styles, since I don't know if this is even feasible.
By the way: my file contains a link to a .tiff image, and pandoc says that it can't fetch it. No need to answer on this, because I've not yet investigated on this issue.
If there is some other example I can send, I'll be happy to do it!
As I said, what would be most useful to me would be a diff between the desired output and the current pandoc output.
I see the same issue of the OP when the source has a linked image resized either in percentage or as a fixed value. Something like:
![](images/tx-gear-icon.png){heigth=10pt}
gives me an image that can't be resized.
I don't know how to compare the current Pandoc output with the desired one. All I can say is that this is what I see in InDesign CS6 when I click on the image frame containing the linked image that I can't resize:
This is when I click on the linked image (not the containing frame):
The parameters in the boxes above can't be accessed.
This is the corresponding ICML code generated by Pandoc:
<Rectangle Self="uec" StrokeWeight="0" ItemTransform="0.05 0 0 0.05 150 -100">
<Properties>
<PathGeometry>
<GeometryPathType PathOpen="false">
<PathPointArray>
<PathPointType Anchor="-150 -100" LeftDirection="-150 -100" RightDirection="-150 -100" />
<PathPointType Anchor="-150 100" LeftDirection="-150 100" RightDirection="-150 100" />
<PathPointType Anchor="150 100" LeftDirection="150 100" RightDirection="150 100" />
<PathPointType Anchor="150 -100" LeftDirection="150 -100" RightDirection="150 -100" />
</PathPointArray>
</GeometryPathType>
</PathGeometry>
</Properties>
<Image Self="ue6" ItemTransform="0.05 0 0 0.05 -150 -100">
<Properties>
<Profile type="string">
$ID/Embedded
</Profile>
<GraphicBounds Left="0" Top="0" Right="6000" Bottom="4000" />
</Properties>
<Link Self="ueb" LinkResourceURI="file:images/tx-gear-icon.png" />
</Image>
</Rectangle>
I see the values, but I can't understand why the can't then be edited in InDesign.
If I export it as an IDML file from InDesign, and open it in Affinity Publisher 2.5, I can select the layer corresponding to the linked image, and I can see it is locked. I can then unlock it, and freely transform it.
So, something is locking the dimensions when importing from the ICML file.
Problem
When converting a file from Markdown → ICML I can't seem to change the size of images in InDesign with graphics frame styles. Setting a value of
{width=10cm}
within my markdown file produces the expected result in InDesign, however, no graphics frame style is explicitly created to accomplish this unlike how Pandoc handles text styles (which works very nicely!) Instead, Pandoc seems to take the image's hard-coded width and height values and apply it as an override to the default graphics frame style.When no explicit width value is set Pandoc's fallback is to look at each image's resolution and set width & height values accordingly. This is also set to be applied as an override to the default graphics frame style.
Because these overrides are set with absolute values I cannot modify the graphics frame style to handle images sizing dynamically within InDesign, the only option appears to be to add fixed image frame sizes to each image within Markdown or break the link to my markdown file and handle the layout manually.
Examples
When set to a fixed width size in Markdown that width is carried over and images behave as expected.
When no width value is set Pandoc falls back on the file's dimensions, this can result in overset images. Note the override styling of the default [Basic Graphics Frame]+ in both screenshots which cannot be removed, as such both of these images cannot be effectively styled within InDesign.
ICML Images Issues.zip
All files needed to reproduce the examples above should be included in this zip. Create a fresh 8.5x11" document and place the generated ICML within a text frame.
Proposed Solution
Instead of relying on the absolute sizing fallback for encoding image sizes in ICML, a generalized graphics frame style could be created with some sensible defaults in the same way that paragraph styles are currently handled in the ICML writer? This way image sizing could be dynamic instead of set with fixed default values that cannot be changed without unlinking and manually fixing the sizing issues.
Caveats & other notes