PDA

View Full Version : Exporting nodes with image blocks... exports images?



celestian
October 1st, 2018, 20:54
So, this is probably a very specific problem and I might be searching in the wrong place but... here is the issues.

When you export with the extension Author (https://www.fantasygrounds.com/forums/showthread.php?41833-Project-Author)it does a little bit of pre-export work to create an export node so that it is exported along with everything else FG does by default.



ExportManager.registerExportNode({ name = "_refmanualindex", label = "Reference Manual", export="reference.refmanualindex", sLibraryEntry="reference_manual"});


The _refmanualindex is created from Story nodes in a ref-manual format. In that creation process I look for "individually placed" image links and create a inline image node that the ref-manuals can use properly to display them.

I've noted that for every single image block a extra copy of the image file (DungeonMapTest1.jpg in this case) is placed into the exported .mod file. Example:

<chapters>...<subchapters>...<refpages>...<blocks>..<id-00002>:


<id-00004>
<align type="string">center</align>
<blocktype type="string">image</blocktype>
<caption type="string">DungeonMapTest1 (2500x3300)</caption>
<image type="image">
<bitmap>images/DungeonMapTest1.jpg</bitmap>
</image>
<imagelink type="windowreference">
<class>imagewindow</class>
<recordname>image.id-00002</recordname>
</imagelink>
<size type="string">378,500</size>
</id-00004>




No where does my custom code add in those images "files/image.id-*" into the Export node list.

Is this part of the default behavior of FG with image blocks? I've searched through my code to doubly to make sure I do not add these images to the export list anywhere else...

My code, simply inserts this ref-manual document node "_refmanualindex" as "reference.refmanualindex" so that when exported and loaded as module users have a link called "Reference Manual" that will load the manual.

I don't think anyone else does this so it could just be what I'm doing was never intended and has some unintended consequences.

The full source of the work can be found in my Author project post. (https://www.fantasygrounds.com/forums/attachment.php?attachmentid=24215&d=1533565384)

I think I've exhausted any possible culprits that I could find and wondering if someone else has a theory.

Mortar
October 1st, 2018, 22:39
Ikael's SWEL is unable to export images within the refmanual either. I believe if IIRC that he said that it can't currently be done through FG.

celestian
October 1st, 2018, 22:44
Ikael's SWEL is unable to export images within the refmanual either. I believe if IIRC that he said that it can't currently be done through FG.

I'm not actually trying to export the images. Just the ref-manual index/nodes. That part works. The other part of /export that I do not manage seems to be adding in a extra image for each one of the images referenced in the image blocks.

I use the export mechanisms in place so users can export whatever they want as normal. This just adds the extra ref-manual nodes. I suspect FG internals is automatically adding duplicates of them because of the image blocks in the ref manual.

Bidmaron
October 1st, 2018, 22:46
Well you cannot edit them in so it has to work somehow. (Putting an image in line to xml is not something notepad++ can do or at least I don’t know how to do it). The way I read the pair was that it was inserting two copies

celestian
October 1st, 2018, 22:57
Well you cannot edit them in so it has to work somehow. (Putting an image in line to xml is not something notepad++ can do or at least I don’t know how to do it). The way I read the pair was that it was inserting two copies

I'm not sure I understand what you're saying. Perhaps this is more clear.

I don't actually mess with image records or files. I just read the Story entry, if there is a link to a image there that meets a certain criteria I then make a similar link to that image record in the ref-manual node. So if the story refers to image-id.00001 in a link then I simply replace the entry for a link of a story to a image block referencing image-id.00001.

Mortar
October 1st, 2018, 23:09
I'm not actually trying to export the images. Just the ref-manual index/nodes. That part works. The other part of /export that I do not manage seems to be adding in a extra image for each one of the images referenced in the image blocks.

I use the export mechanisms in place so users can export whatever they want as normal. This just adds the extra ref-manual nodes. I suspect FG internals is automatically adding duplicates of them because of the image blocks in the ref manual.

Not sure I follow you. There is code for one image in there, plus the imagelink to enable you pop out that image into a separate window in FG.

The imagelink xml needs to point an a node within the "<image>" tag to work, which then bitmaps to the actual image itself.

celestian
October 1st, 2018, 23:21
Not sure I follow you. There is code for one image in there, plus the imagelink to enable you pop out that image into a separate window in FG.

The imagelink xml needs to point an a node within the "<image>" tag to work, which then bitmaps to the actual image itself.

Correct. The <image>...<image> records and files are all handled by existing export technology. I don't touch it. I just reference those links in my ref-manual. Same way you'd edit a ref-manual by hand and add the reference. Those records exist in the db.xml of any export with or without Author (assuming you tick the IMAGE check).

Edit: Attached a sample exported db.xml using /export with Author. Maybe this will help for those not sure how this works. It's a simple single chapter, 2 story entries, the first one has 1 inline image.

That image exists in the .mod file twice now. If I added another inline image of it on the second story entry there would be 3.

Here are the settings I used when doing it.
https://i.imgur.com/uMQhwq8.png

Contents of file:
https://i.imgur.com/gkFemQD.png

Mortar
October 1st, 2018, 23:27
There is still only one image there. It just accessed in two different ways within FG to support different functions. So I am not sure how you are seeing double images. I am a little slow tonight so I am not quite getting what you see as the problem.

edit- is it because you see that particular name twice?

celestian
October 1st, 2018, 23:31
There is still only one image there. It just accessed in two different ways within FG to support different functions. So I am not sure how you are seeing double images. I am a little slow tonight so I am not quite getting what you see as the problem.

edit- is it because you see that particular name twice?

I think I see the confusion. I'm not talking about while viewing the image in the ref-manual. I'm talking about in the .mod file. The reference manual looks fine.

https://i.imgur.com/h9HnugP.png

Mortar
October 1st, 2018, 23:35
Confusion clearing up. So in the exported mod file you end up with having two copies of the image in question?


Ah...now I see the extra image that my desktop didn't want to cooperate with me

celestian
October 1st, 2018, 23:41
Confusion clearing up. So in the exported mod file you end up with having two copies of the image in question?


Yeap, for everytime the image is referenced in the image block the exporter adds another image file ;( If you have it inline 5 times, there will be 6 (1 because I told it to export images like you always do, 5 for the other inline references).

That's the bit I can't seem to find a cause for in my code.

Mortar
October 1st, 2018, 23:47
Create an images folder in your mod. Change all the bitmaps to read: images/[picture name here]

You need to check all the image node and adjust those bitmaps as well. This should help you a bit, especially if you link to an image multiple times.

celestian
October 1st, 2018, 23:56
Create an images folder in your mod. Change all the bitmaps to read: images/[picture name here]

You need to check all the image node and adjust those bitmaps as well. This should help you a bit, especially if you link to an image multiple times.

Unzipping the file will "fix" the problem because the same named files can't exist more than once. I can manage the .mod manually but /export already handles the images. I'm trying to figure out why it's placing the extra duplicate images when I'm not asking it to do so during /export.

Mortar
October 2nd, 2018, 00:14
It would seem that Author is picking up each link pointing at one image as a link to separate images. Might be possibly picking up on that the tow link formats, so it doesn't recognize that its the same image.


edit: I haven't spent much time with author yet, but based on the code snippet you linked made me think of this.

Bidmaron
October 2nd, 2018, 00:42
I think Moon Wizard or Trenloe are going to have to leap in

celestian
October 2nd, 2018, 02:24
I think Moon Wizard or Trenloe are going to have to leap in

That was my thought also. I'm kinda at the limit of what I can find unless im just blind. I know Moon is busy with FGU but I'm hoping it's something obvious he'll know the mechanics of I am not aware of.

There is a work around for folks with the problem (just unzip and rezip the mod created by FG) so it's not a huge deal but it does bother me as I'd love to make this as clean as possible so people won't have to do anything outside of FG.

Moon Wizard
October 9th, 2018, 05:02
Apologies. I've been heads down working on FGU; but bookmarked this one to answer when I came back up with some time.

As I suspected and verified in the code, there is no tracking of whether an image node file has already been exported. Thus, a file is exported every time an image node is exported. Fixing this requires an update to the client to track and ignore additional requests to attach the same file; so it will have to wait for the next round of client updates.

Regards,
JPG

celestian
October 9th, 2018, 07:50
Apologies. I've been heads down working on FGU; but bookmarked this one to answer when I came back up with some time.

As I suspected and verified in the code, there is no tracking of whether an image node file has already been exported. Thus, a file is exported every time an image node is exported. Fixing this requires an update to the client to track and ignore additional requests to attach the same file; so it will have to wait for the next round of client updates.

Regards,
JPG

Thanks for checking into this. Can you do one additional thing for me while you're at it? Add a name for the stringcontrol labeled "A" in the export selection window? I can't merge/replace it when my own version of the "A" that allows you to select ALL of the items at once. Right now I just position a A ontop of that A but if they use funky fonts it shows. It's in <windowclass name="export" /> Around here in utility/utility_export.xml



<stringcontrol>
<anchored to="list" position="aboveleft" offset="0,3" width="20" />
<font>sheetlabel</font>
<lineoffset default="on">-1</lineoffset>
<static textres="export_label_listall" />
<center />
</stringcontrol>



Thanks again!

Mortar
October 11th, 2018, 15:17
Doing some experimenting with Project Author as I work on my next conversion(s). If you don't check the "images" toggle in the export window there will only be one copy of the image in the export. Since you have added the image in-line as part of the export, I believe that your extension is already exporting the image anyways. If you check the toggle you are telling both the extension AND FG's default exporter you want the image.

Something to think about.

Mortar
October 11th, 2018, 22:35
I didn't check the Image when I exported this. One copy of the image was exported. I also don't have the "<image>" section in the exported module, so I if I click on the image to use the image link an error gets thrown (but I was expecting that error.

Not sure if that helps you out figure out what is happening and why or not.

24947

celestian
October 11th, 2018, 23:17
I didn't check the Image when I exported this. One copy of the image was exported. I also don't have the "<image>" section in the exported module, so I if I click on the image to use the image link an error gets thrown (but I was expecting that error.

Not sure if that helps you out figure out what is happening and why or not.

24947

Author code doesn't add the image to the export list FYI.

Use the same image in the ref-manual multiple times and each time it'll be added to the .mod file. This was the issue myself and Moon are talking about.