filenames for epub images in images folder

jbzech
Posts: 35

filenames for epub images in images folder

Wed Jan 04, 2012 1:30 am

Hi,

While I am pretty happy with the output of the epub ant transform, I'm having trouble with the way the transform changes the names of my image files when it copies them into the epub images folder. Some element of the transform is changing my image filenames and I can't figure out where it occurs (I'm new to XSLT & ANT). Right now, I'm only using covers as images, but this may be a problem with other images as well.

This seems to be the part of the output where the trouble occurs:

Code: Select all

images:
     [xslt] Processing \\lpvault\home\name\docs\book\e_book\transformOutput\cover.html to \\lpvault\home\name\docs\book\e_book\temp\cover.html
     [xslt] Loading stylesheet C:\Program Files\Oxygen XML Editor 13\frameworks\docbook\xsl\epub\images.xsl
     [xslt] File \\lpvault\home\name\docs\book\e_book\ancillaryFiles\images\epub_cover.jpg was copied to \\lpvault\home\name\docs\book\e_book\transformOutput\images\__lpvault_home_name_docs_book_e_book_ancillaryFiles_images_epub_cover_.jpg
     [xslt] Processing \\lpvault\home\name\docs\book\e_book\transformOutput\content.opf to \\lpvault\home\name\docs\book\e_book\temp\content.opf
     [xslt] Loading stylesheet C:\Program Files\Oxygen XML Editor 13\frameworks\docbook\xsl\epub\addImagesContentOpf.xsl
     [copy] Copying 1 file to \\lpvault\home\name\docs\book\e_book\transformOutput


In particular, it's the

Code: Select all

[xslt] File \\lpvault\home\name\docs\book\e_book\ancillaryFiles\images\epub_cover.jpg was copied to \\lpvault\home\name\docs\book\e_book\transformOutput\images\__lpvault_home_name_docs_book_e_book_ancillaryFiles_images_epub_cover_.jpg


that bothers me, as I don't want to change the filename or I'd like to give it a simpler filename.

I thought I would need to customized the images.xsl file, but that doesn't seem to do it. Not sure if the problem is in the docbook stylesheets or in your particular epub transform. Can you help me with this?

Thank you.
sorin_ristache
Posts: 4144

Re: filenames for epub images in images folder

Wed Jan 04, 2012 1:24 pm

Hello,

The file names of images must be unique for avoiding overwriting an image with another one having the same name when the image files are copied to the folder which will go in the EPUB output. In general this inclusion of copies of the original image files in the EPUB output is necessary because the images may come from a folder outside the main folder with the source XML files or even from a Web server while the EPUB file must contain all dependent files (including images) regardless of their original location. The name prefix of the duplicate image file depends on the original file path and aims to avoid name clashes (and overwriting) of images with the same name but originally located in different folders.

You cannot correct these long image file names by just editing some XSLT stylesheet because they are computed in Java code. Anyway an EPUB reader application does not care about the image name from the EPUB that it will load and display. Isn't it easier to work on/edit only the XML source files and the images included in these XML files and just let the EPUB reader handle the EPUB transformation output?


Regards,
Sorin
jbzech
Posts: 35

Re: filenames for epub images in images folder

Thu Jan 05, 2012 6:31 pm

The issue I'm having is that I run a batch file and perl script after transformation to make a few additional changes to the epub (my Batch/Perl is much better than my XSLT/ANT). Windows XP command line, for some reason, chokes on the long filename of the image file (my project directories that hold the images before processing have fairly long names so when those get added as prefix the filename is extremely long). If I can just shorten this prefix procedure, I can get around this problem. Otherwise, Windows XP can't do anything to this file.

I don't have this problem in Windows 7, where I make a filename change part of the batch/perl script after the epub is made. But Windows XP can't do anything with the file because the name is too long and it crashes out. I can try to upgrade my colleague's version of windows, but I was hoping to avoid asking her to do that.
sorin_ristache
Posts: 4144

Re: filenames for epub images in images folder

Fri Jan 06, 2012 10:19 am

If there are no conflicts between the image file names (the same image file name in different original folders, the folders from where the images are copied) you should follow these steps:

  • unzip the EPUB file in a short file path (for example C:\temp, for avoiding the long file names problem on Windows XP). If the file names are too long first you have to build the EPUB again from XML + image files stored in a short file path (for example C:\temp) in order to have shorter file names in the EPUB result
  • rename each image file from the EPUB by removing the long prefix, make sure you keep the same name in the images folder and in the HTML files
  • zip all the files again as an EPUB file

We will consider adding a parameter to the EPUB transformarion for preserving the image file names when including them in the EPUB result.


Regards,
Sorin

Return to “DocBook”

Who is online

Users browsing this forum: No registered users and 0 guests