Package: photon
Version: 0.4.6-1.1
Severity: normal
Tags: patch

In short, the issue is with picture files ending with suffix '.JPG' in
capital letters, and creating the html page which renders the picture
in it's original size. In the generated html, the picture file name suffix
is converted to lower case, while the file it self remains with upper
case suffix. As a result, the browser cant find the file having the
picture.

In my case, I have the pictures like the following (output of 'ls -R
pict'):

pict/:
capital
small

pict/capital:
P1.JPG
P2.JPG

pict/small:
p7.jpg
p8.jpg


Photon with command line 'photon -o photon_out pict' generates the following 
files
(output of 'ls -RF photon_out'):

------------------------------------------------------------------
photon_out:
capital/
index.html
small/
<some lines removed here>

photon_out/capital:
160x120/
640x480/
800x600/
index.html
original/
P1_1024x768.html
P1_160x120.html
P1_640x480.html
P1_800x600.html
P1.html
P2_1024x768.html
P2_160x120.html
P2_640x480.html
P2_800x600.html
P2.html
<some lines removed here>

photon_out/capital/160x120:
P1.jpg
P2.jpg

photon_out/capital/640x480:
P1.jpg
P2.jpg

photon_out/capital/800x600:
P1.jpg
P2.jpg

photon_out/capital/original:
P1.JPG
P2.JPG

photon_out/small:
160x120/
640x480/
800x600/
index.html
original/
p7_1024x768.html
p7_160x120.html
p7_640x480.html
p7_800x600.html
p7.html
p8_1024x768.html
p8_160x120.html
p8_640x480.html
p8_800x600.html
p8.html
<some lines removed here>

photon_out/small/160x120:
p7.jpg
p8.jpg

photon_out/small/640x480:
p7.jpg
p8.jpg

photon_out/small/800x600:
p7.jpg
p8.jpg

photon_out/small/original:
p7.jpg
p8.jpg
------------------------------------------------------------------


The following extract from file 'photon_out/capital/P1.html' shows the
wrong reference to image P1.JPG.

      <img hspace="3" vspace="3" border="0" src="original/P1.jpg"
      alt="P1.jpg">


I fixed this problem by modifying the filename into lowercase '.jpg'
suffix when copying the picture into the 'original' directory. It can
be done by adding the following line

          filename = re.sub('^(.*)\.[^.]+$',"\\1.jpg",filename)

into function

     def process_file(sourcedir, relativepath, filename): # 
       """ Create for this file all thumbnails and return the size of the image 
"""

like this

def process_file(sourcedir, relativepath, filename): # 
  """ Create for this file all thumbnails and return the size of the image """

  srcfile = os.path.join(sourcedir, relativepath, filename)
  # We need to detect, if a image can be draw at the screen.
  # If original_size is always smaller than any sizelist (without thumbnail)
  # then image is not draw to the screen. So keep a flag that can draw this
  # image at the original_size
  npicsconverted = 0
  pic = {}
  try:
    im = Image.open(srcfile)
    if options['verbose_level'] >= 1:
      print 'Processing image', srcfile, im.format, "%dx%d" % im.size, im.mode
  except IOError, err:
    print "cannot create thumbnail for", srcfile ,"(", err.strerror, ")"
  else:
    # Foreach size of the image, resize them only when it's different from 
Original
    pic['filename'] = filename
    pic['original_size'] = im.size
    pic['extra_resolution'] = []
    if options['exif']:
      file = open(srcfile, 'rb')
      pic['exif'] = EXIF.process_file(file)
    if im.size[1] > im.size[0]: # Keep aspect ratio
      pic['aspect'] = 34
      pic['ratio'] = float(im.size[1])/im.size[0]
    else:
      pic['aspect'] = 43
      pic['ratio'] = float(im.size[0])/im.size[1]

    for (w,h) in options['sizelist'] + [(-1,-1)]:
      if w == -1 and h == -1: # Small hack to process code at the end of the 
loop
        # If no image is converted (without counting thumbnail), then copy the 
original
        # original size can not be in the 'sizelist'
        if npicsconverted<2 and (0,0) not in options['sizelist']:
          (w,h) = (0,0)
          pic['extra_resolution'].append((0,0))
        else:
          break
      if w == 0 and h == 0: # Special case when it is a original file
        if options['forcecompress']:
          (w,h) = im.size
        else:
          subdir = 'original'
          destdir = os.path.join(options['output_directory'], relativepath, 
subdir)

          # Markku Majaniemi @ 21-Nov-2010
          # the following fix is for uppercase picture filenames (e.g. 
"P1.JPG").
          # make the copied file's name to lower case ("P1.jpg")
          filename = re.sub('^(.*)\.[^.]+$',"\\1.jpg",filename)

          destfile = os.path.join(destdir, filename)
          if file_is_newer(destfile, srcfile):
            safe_mkdir(destdir)
            shutil.copyfile(srcfile, destfile)
          npicsconverted+=1

          # code continues...


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages photon depends on:
ii  python                  2.6.6-3+squeeze1 interactive high-level object-orie
ii  python-central          0.6.16+nmu1      register and build utility for Pyt
ii  python-imaging          1.1.7-2          Python Imaging Library

Versions of packages photon recommends:
ii  dcraw                         8.99-1+b1  decode raw digital camera images
ii  gimp                          2.6.10-1   The GNU Image Manipulation Program

photon suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to