Inserting image as a tag causes file bloat because the image is inserted multiple times

I’m relatively new to Scrivener so I may be taking the wrong approach; please let me know how to handle the case in which the same image is re-used multiple times.

I am trying to include a text bubble conversation in my ebook. Next to each person speaking in the conversation, I want to place a cartoon head (image).

To do this, I created a custom Project Format, and I created a paragraph style for each person in the conversation. I then used the Compile Styles menu to add the styles for each person; to these styles, I added an image via the prefix option. For example: <$Img:Tiger> .

When I compile the book, the images now show up as I want them to-- great!

However, each time I add a conversation, the compiled book’s file size increases dramatically-- for example, I added 20 lines of dialog and the book’s file size increased by 400 kb. So, it appears that Scrivener is inserting the image for each speaker each time an image tag appears, rather than linking all uses of a single image to one file. (The image of the speaker shows up with each line of dialog.)

This is very wasteful and causes the book file to be much bigger than it should be. What’s the right way to insert an image so that it can be used again and again within a file without increasing the file size?

EDIT: Yes, it’s definitely the case that the image is being duplicated each time it is inserted. I tried exporting as ePUB and opened the file in Sigil, which shows “Tiger.jpg” “Tiger1.jpg” “Tiger2.jpg” and so on, one for each usage.

Hmm, strange, I cannot reproduce this - for me only one image file is created when I try this. Would it be possible to set up a sample project showing the issue, zip it up and attach it to your reply here (using “Attachments” below the reply area)? Alternatively, could you zip up your existing project and send it to us at mac.support AT literatureandlatte.com?

Thanks and all the best,
Keith

Here is a sample project that only includes 12 lines of dialog plus my HTML/CSS (as a custom Project Format-- let me know if it’s not included.)

To reproduce the issue, just compile using the custom project format as KF8. Then, go back to the project, copy-and-paste the lines of dialog, and compile again. The new file will be hundreds of kB larger than the old one.
TigerTest.scriv.zip (130 KB)

Great, thanks for that. I’ve found the issue - ticking “Raw Markup” for styles ends up removing the inner flags that tell Scrivener that an image is a tagged image that has been used throughout. I have fixed this for the next free update, 3.0.3, which should not be too much longer.

That’s a very clever use of style prefixes and suffixes, by the way! One thing I would recommend is to move those prefixes and suffixes into the “Paragraph prefix/suffix” fields rather than just “Prefix/suffix”, since they need wrapping around the entire paragraph. I’d also think twice about including the

tags since they can get added automatically by Scrivener and could cause clashes. These are just recommendations to avoid syntax errors in the ebook, though - if you test and the ebook comes out fine, then there’s no need to change anything, of course. (I did fix another bug while I was at this that caused the prefix/suffix text field heights to expand when there was return characters in there, obscuring other content below them.)

All the best,
Keith

Thanks Keith, that’s great news! I appreciate the tips as well. I didn’t understand the distinction between “prefix/suffix” and “paragraph prefix/suffix.”

The difference won’t have any effect if you only have a single paragraph of each style at a time. Basically, the prefix/suffix gets placed around the whole styled range, which may contain any number of paragraphs. The paragraph prefix/suffix gets placed around each paragraph within a style.

In your case, you probably do want it around the whole block, but you wouldn’t want the

tags around the whole block - you’d want that on a paragraph-by-paragraph basis. (Or not at all and leave Scrivener to add those.)

If you only ever have one paragraph at a time as in your example, though (that is, one paragraph in one style, then the next paragraph in another, then back again), then the distinction won’t make any difference.

All the best,
Keith