質問

I need to parse an IDML file and save the images separately from that file in formats for the Web. Can I do that IDMLlib? And if it's possible then can you show me some examples? P.S. The documentation of that library is awful, and the examples are horrible.

役に立ちましたか?

解決 2

IDML files, very famously, do not 'contain' the base-64 encoded image data for linked images, only for embedded ones. For linked images only their physical locations on the original machine are stored.

Embedded images are found inside "Spread_uXX.xml" files, in a tag <Image>. This tag contains the image dimensions and some other meta-information, and a sub-tag <Contents> that lists the CDATA in Base-64. Be warned: there may be more than a single block of CDATA for each image.

The type of embedded images may or may not be the same as the original; the Image tag should declare the type in an attribute ImageTypeName. If the file format is not one you can use 'for the web', you need to convert it yourself.

I don't use IDMLlib so I cannot comment on its examples style.

他のヒント

Yes, you can do it with IDMLlib, or by writing your own IDML parser (which is what I've done).

Images in IDML can be either embedded or linked. To extract an embedded image, you need to find the content node, as Jongware has described.

Here is an example of the IDML for an image that is not embedded:

<Image ItemTransform="1 0 0 1 -32.04 -35.04" Self="uf4" Name="$ID/" Visible="true" AppliedObjectStyle="ObjectStyle/$ID/[None]" GradientFillHiliteAngle="0" GradientFillHiliteLength="0" LocalDisplaySetting="Default" GradientFillAngle="0" GradientFillLength="0" GradientFillStart="0 0" VerticalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" HorizontalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" OverriddenPageItemProps="" LastUpdatedInterfaceChangeCount="" TargetInterfaceChangeCount="" ParentInterfaceChangeCount="" ImageTypeName="$ID/JPEG" ImageRenderingIntent="UseColorSettings" EffectivePpi="300 300" ActualPpi="300 300" Space="$ID/#Links_RGB">
<Properties>
    <Profile type="string">$ID/None</Profile>
    <GraphicBounds Right="64.08" Left="0" Bottom="70.08" Top="0"/>
</Properties>
<TextWrapPreference TextWrapMode="None" TextWrapSide="BothSides" ApplyToMasterPageOnly="false" Inverse="false">
    <Properties>
        <TextWrapOffset Right="0" Left="0" Bottom="0" Top="0"/>
    </Properties>
    <ContourOption ContourPathName="$ID/" IncludeInsideEdges="false" ContourType="SameAsClipping"/>
</TextWrapPreference>
<Link Self="uf7" LinkResourceSize="0~6561" LinkImportTime="2012-09-03T15:23:30" LinkImportModificationTime="2012-05-22T15:25:15" LinkImportStamp="file 129821703152428740 25953" ExportPolicy="NoAutoExport" ImportPolicy="NoAutoImport" CanPackage="true" CanUnembed="true" CanEmbed="true" ShowInUI="true" LinkObjectModified="false" LinkResourceModified="false" LinkClientID="257" LinkClassID="35906" StoredState="Normal" LinkResourceFormat="$ID/JPEG" LinkResourceURI="file:D:/Pictures/hkp.jpg" AssetID="$ID/" AssetURL="$ID/"/>
<ClippingPathSettings IncludeInsideEdges="false" Index="-1" AppliedPathName="$ID/" InsetFrame="0" Tolerance="2" Threshold="25" UseHighResolutionImage="true" RestrictToFrame="false" InvertPath="false" ClippingType="None"/>
<ImageIOPreference AlphaChannelName="$ID/" AllowAutoEmbedding="true" ApplyPhotoshopClippingPath="true"/>
</Image>

To find the image, you need to find the Link node that is a child of the Image node, and extract the value of the LinkResourceURI attribute, which is the path to the image. This is a local path, so you need to do all this on the same machine the IDML was authored on.

For an IDML document to be portable between machines, you need to embed the images using the Links panel in InDesign.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top