summaryrefslogtreecommitdiffstats
path: root/sci-geosciences/happycamel/files
diff options
context:
space:
mode:
Diffstat (limited to 'sci-geosciences/happycamel/files')
-rw-r--r--sci-geosciences/happycamel/files/HappyCamel-optional-correlate.diff38
-rw-r--r--sci-geosciences/happycamel/files/happycamel-ds-icons.patch167
-rw-r--r--sci-geosciences/happycamel/files/happycamel-v1-beta3-ds-features.patch322
3 files changed, 527 insertions, 0 deletions
diff --git a/sci-geosciences/happycamel/files/HappyCamel-optional-correlate.diff b/sci-geosciences/happycamel/files/HappyCamel-optional-correlate.diff
new file mode 100644
index 0000000..0b57729
--- /dev/null
+++ b/sci-geosciences/happycamel/files/HappyCamel-optional-correlate.diff
@@ -0,0 +1,38 @@
+diff -dPNur HappyCamel.orig/cli.py HappyCamel/cli.py
+--- HappyCamel.orig/cli.py 2010-01-29 09:23:25.000000000 +0100
++++ HappyCamel/cli.py 2011-08-14 09:21:16.000000000 +0200
+@@ -188,6 +188,8 @@
+ help = "The number of seconds the camera's time runs before the GPS device (note that photo's and tracklogs may or may not compensate for UTC and timezone. You may need to correct this manually. Also see -r.)")
+ parser.addOption("--fix-dates", var = "fix_dates", default = defaults["fix_dates"],
+ type = "bool", bool_action = True, help = "If the clock difference is known (via --calibrate or --clock-difference), shift the times in the image metadata to their proper value. Currently set to %default")
++ parser.addOption("--fix-locations", var = "fix_locations", default = defaults["fix_locations"],
++ type = "bool", bool_action = True, help = "Correlate GPS track with image timestamps to get geolocation information. Currently set to %default")
+
+ # The options relating to interpolation
+ parser.addHelpRule("\nOptions relating to interpolation of the location:")
+diff -dPNur HappyCamel.orig/config.py HappyCamel/config.py
+--- HappyCamel.orig/config.py 2010-01-29 09:23:25.000000000 +0100
++++ HappyCamel/config.py 2011-08-14 09:19:24.000000000 +0200
+@@ -56,7 +56,8 @@
+ "flickr_user" : [str, "Flickr", "Default user", None],
+
+ # The options regarding metadata writing
+- "fix_dates": [bool, "Metadata writing", "Fix dates", False],
++ "fix_dates" : [bool, "Metadata writing", "Fix dates", False],
++ "fix_locations": [bool, "Metadata writing", "Fix locations", False],
+
+ # The options regarding interpolation
+ "elevation_mode": [int, "Interpolation", "Elevation", 1],
+diff -dPNur HappyCamel.orig/main.py HappyCamel/main.py
+--- HappyCamel.orig/main.py 2010-01-29 09:23:25.000000000 +0100
++++ HappyCamel/main.py 2011-08-14 09:23:51.000000000 +0200
+@@ -500,6 +500,9 @@
+ """ Match the photo's in photo_list to the location sources in loc_sources,
+ clean up the photo list and return a list of unmatched photo's. """
+
++ if not self.conf.get("fix_locations"):
++ return []
++
+ # Do the matching
+ photo_list.matchTracks(loc_sources.getLocationSources(), elevation_mode,
+ max_deviation, use_outside)
diff --git a/sci-geosciences/happycamel/files/happycamel-ds-icons.patch b/sci-geosciences/happycamel/files/happycamel-ds-icons.patch
new file mode 100644
index 0000000..439f049
--- /dev/null
+++ b/sci-geosciences/happycamel/files/happycamel-ds-icons.patch
@@ -0,0 +1,167 @@
+diff -dPNur HappyCamel.current/cli.py HappyCamel/cli.py
+--- HappyCamel.current/cli.py 2013-08-27 05:13:35.000000000 +0200
++++ HappyCamel/cli.py 2013-09-24 19:46:02.000000000 +0200
+@@ -257,6 +257,10 @@
+ var = "show_waypoints",
+ default = defaults["show_waypoints"],
+ help = "Show the waypoints in the KMZ file. Currently set to %default.")
++ parser.addOption("--google-maps", type = "bool", bool_action = True,
++ var = "for_google_maps",
++ default = defaults["for_google_maps"],
++ help = "Generate for google-maps. Currently set to %default.")
+
+ # The options relating to image parsing
+ parser.addHelpRule("\nUsually, metadata is read through the internal library, but written through the external Exiftool command. Using Exiftool is much slower, but using the internal library for writing carries some risk as it is not as mature.\nThe following options influence this behavior:")
+@@ -333,6 +337,7 @@
+ options["between_color"] = False
+ options["between_width"] = False
+ options["show_waypoints"] = False
++ options["for_google_maps"]= True
+
+ # Check if the user specified any photo's
+ if (len(args) < 1) and not (options["report_times"] or options["save_config"]):
+diff -dPNur HappyCamel.current/config.py HappyCamel/config.py
+--- HappyCamel.current/config.py 2013-08-27 05:13:35.000000000 +0200
++++ HappyCamel/config.py 2013-09-24 19:46:49.000000000 +0200
+@@ -77,6 +77,7 @@
+ "between_color": [str, "KMZ File", "Between color", "60ffffff"],
+ "between_width": [float, "KMZ File", "Between width", 2.0],
+ "show_waypoints": [bool, "KMZ File", "Show waypoints", False],
++ "for_google_maps": [bool, "KMZ File", "Generate for Google Maps", True],
+ "order": [str, "KMZ File", "Order", "D"],
+ "image_size": [int, "KMZ File", "Pixels", 200],
+ "icon_size": [int, "KMZ File", "Icon pixels", 0],
+diff -dPNur HappyCamel.current/kmlhandler.py HappyCamel/kmlhandler.py
+--- HappyCamel.current/kmlhandler.py 2013-08-27 05:13:35.000000000 +0200
++++ HappyCamel/kmlhandler.py 2013-09-24 19:53:49.000000000 +0200
+@@ -59,7 +59,7 @@
+ self.between_tracks_width = between_tracks_width
+
+ def writeKML(self, out_fp, write_photos = True, write_waypoints = True,
+- write_track = True, write_between_tracks = True):
++ write_track = True, write_between_tracks = True, for_google_maps = True):
+ """ Write a KML file to the specified file pointer out_fp. The arguments
+ specify which parts of the file should be included. If write_photos is
+ True, thumbnails should be included. If write_waypoints is True,
+@@ -80,7 +80,7 @@
+
+ if (write_photos):
+ self.logger.debug("Writing photo folder")
+- self.writePhotos(out_fp)
++ self.writePhotos(out_fp, for_google_maps)
+
+ if (write_waypoints):
+ self.logger.debug("Writing waypoints folder")
+@@ -92,7 +92,7 @@
+
+ out_fp.write('</Document>\n')
+
+- def writePhotos(self, out_fp):
++ def writePhotos(self, out_fp, for_google_maps):
+ """ Write the photo references with comments and stuff to the file pointer
+ out_fp . """
+
+@@ -116,10 +116,9 @@
+ out_fp.write('<Folder>\n')
+ out_fp.write(' <name>Images</name>\n')
+ # Write each thumbnail as a placemark
++
+ for photo in self.photo_list:
+ if (photo in self.thumbnail_names): # Only process if there's a thumbnail
+- location = photo.getLocation()
+-
+ if (self.use_icons):
+ out_fp.write(' <Style id="photo_%s">\n' % self.thumbnail_names[photo])
+ out_fp.write(' <IconStyle>\n')
+@@ -133,6 +132,10 @@
+ out_fp.write(' </LabelStyle>\n')
+ out_fp.write(' </Style>\n')
+
++ for photo in self.photo_list:
++ if (photo in self.thumbnail_names): # Only process if there's a thumbnail
++ location = photo.getLocation()
++
+ out_fp.write(' <Placemark>\n')
+ out_fp.write(' <name>%s</name>\n' % photo.getName())
+ out_fp.write(' <description><![CDATA[')
+@@ -157,9 +160,22 @@
+ out_fp.write(' <Snippet>%s</Snippet>\n' % photo.getName())
+
+ if (self.use_icons):
+- out_fp.write(' <styleUrl>#photo_%s</styleUrl>\n' % self.thumbnail_names[photo])
++ if (for_google_maps):
++ out_fp.write(' <StyleMap><Pair><Style>\n')
++ out_fp.write(' <IconStyle>\n')
++ out_fp.write(' <scale>1.5</scale>\n')
++ out_fp.write(' <Icon>\n')
++ out_fp.write(' <href>icons/%s</href>\n' % self.thumbnail_names[photo])
++ out_fp.write(' </Icon>\n')
++ out_fp.write(' </IconStyle>\n')
++ out_fp.write(' <LabelStyle>\n')
++ out_fp.write(' <scale>0.2</scale>\n')
++ out_fp.write(' </LabelStyle>\n')
++ out_fp.write(' </Style></Pair></StyleMap>\n')
++ else:
++ out_fp.write(' <styleUrl>#photo_%s</styleUrl>\n' % self.thumbnail_names[photo])
+ else:
+- out_fp.write(' <styleUrl>#photo_mark</styleUrl>\n')
++ out_fp.write(' <styleUrl>#photo_mark</styleUrl>\n')
+ out_fp.write(' <Point>\n')
+ if (location[2]):
+ out_fp.write(' <altitudeMode>clampToGround</altitudeMode>\n')
+@@ -202,7 +218,7 @@
+ # Write the actual waypoints
+ for waypoint in waypoints:
+ out_fp.write(' <Placemark id="%s">\n' % waypoint[3])
+- out_fp.write(' <styleUrl>waypoint_style</styleUrl>\n')
++ out_fp.write(' <styleUrl>#waypoint_style</styleUrl>\n')
+ out_fp.write(' <Point>\n')
+ out_fp.write(' <coordinates>%.5f,%.5f,%.3f</coordinates>\n' % (waypoint[1], waypoint[0], (waypoint[2] or 0)))
+ out_fp.write(' </Point>\n')
+@@ -399,7 +415,7 @@
+ self.logger.error("Couldn't make a thumbnail of image %s." % photo.getName())
+
+ def writeFile(self, write_photos = False, write_waypoints = False,
+- write_track = False, write_between_tracks = False):
++ write_track = False, write_between_tracks = False, for_google_maps = True):
+ """ Write the KMZ file. The arguments specify which parts of the file should
+ be included. If write_photos is True, thumbnails should be included.
+ If write_waypoints is True, waypoints should be included. If write_track
+@@ -440,7 +456,7 @@
+ self.between_tracks_color, self.between_tracks_width,
+ self.photos_clickable, self.photos_url, bool(self.icon_size))
+ kml_fp = StringIO.StringIO()
+- kml.writeKML(kml_fp, write_photos, write_waypoints, write_track, write_between_tracks)
++ kml.writeKML(kml_fp, write_photos, write_waypoints, write_track, write_between_tracks, for_google_maps)
+
+ # Write the KML file to the ZIP archive
+ out_file.writestr("base.kml", kml_fp.getvalue())
+diff -dPNur HappyCamel.current/main.py HappyCamel/main.py
+--- HappyCamel.current/main.py 2013-08-27 05:13:35.000000000 +0200
++++ HappyCamel/main.py 2013-09-24 19:50:50.000000000 +0200
+@@ -264,7 +264,8 @@
+ self.conf.get("url"),
+ self.conf.get("show_waypoints"),
+ self.conf.get("show_track"),
+- self.conf.get("show_between_tracks"))
++ self.conf.get("show_between_tracks"),
++ self.conf.get("for_google_maps"))
+
+ def getLocSources(self, input_list):
+ """ Build and return a GeoSources instance with all possible sources of
+@@ -533,7 +534,7 @@
+ def writeKMZFile(self, gpx_files, photo_list, file_path, order, image_size, icon_size,
+ title, track_color, track_width, between_color,
+ between_width, clickable, photos_url, show_waypoints, show_track,
+- show_between_tracks):
++ show_between_tracks, for_google_maps):
+
+ """ Write the KMZ file with the specified options. """
+
+@@ -543,5 +544,5 @@
+
+ kmz.writeFile(write_photos = True,
+ write_waypoints = show_waypoints, write_track = show_track,
+- write_between_tracks = show_between_tracks)
++ write_between_tracks = show_between_tracks, for_google_maps = for_google_maps)
+
diff --git a/sci-geosciences/happycamel/files/happycamel-v1-beta3-ds-features.patch b/sci-geosciences/happycamel/files/happycamel-v1-beta3-ds-features.patch
new file mode 100644
index 0000000..4bf9abc
--- /dev/null
+++ b/sci-geosciences/happycamel/files/happycamel-v1-beta3-ds-features.patch
@@ -0,0 +1,322 @@
+diff -dPNur happycamel-v1-beta3/HappyCamel/cli.py happycamel-v1-beta3-ds/HappyCamel/cli.py
+--- happycamel-v1-beta3/HappyCamel/cli.py 2008-04-17 21:25:10.000000000 +0200
++++ happycamel-v1-beta3-ds/HappyCamel/cli.py 2008-11-19 13:58:07.000000000 +0100
+@@ -221,11 +221,16 @@
+ parser.addOption("--image-size", metavar = "pixels", var = "image_size",
+ type = "int", default = defaults["image_size"],
+ help = "The size of the long side of the photo in the KMZ file. Currently set to %default.")
++ parser.addOption("--icon-size", metavar = "pixels", var = "icon_size",
++ type = "int", default = defaults["icon_size"],
++ help = "The size of the long side of the icon in the KMZ file. Currently set to %default.")
+ parser.addOption("--title", metavar = "title", var = "title",
+ default = defaults["title"], help = "The title of your KMZ file. Currently set to \"%default\".")
+ parser.addOption("--clickable", var = "clickable", type = "bool",
+ bool_action = True, default = defaults["clickable"],
+ help = "It true, make the images clickable so they are shown in your web browser. WARNING: When using disk photos, this is not portable across computers, unless the photo's are placed at exactly the same path as on the original machine. Currently set to %default.")
++ parser.addOption("--url", var = "url",
++ default = "", help = "Defines URL there the photos are published. Currently set to %default.")
+ parser.addOption("--track", type = "bool", bool_action = True,
+ var = "show_track", default = defaults["show_track"],
+ help = "Show the GPS track in the KMZ file. Currently set to %default.")
+@@ -315,8 +320,10 @@
+ options["kmz_file"] = False
+ options["order"] = False
+ options["image_size"] = False
++ options["icon_size"] = False
+ options["title"] = False
+ options["clickable"] = False
++ options["url"] = False
+ options["show_track"] = False
+ options["track_color"] = False
+ options["track_width"] = False
+diff -dPNur happycamel-v1-beta3/HappyCamel/config.py happycamel-v1-beta3-ds/HappyCamel/config.py
+--- happycamel-v1-beta3/HappyCamel/config.py 2008-04-17 21:25:10.000000000 +0200
++++ happycamel-v1-beta3-ds/HappyCamel/config.py 2008-11-19 13:54:41.000000000 +0100
+@@ -78,8 +78,10 @@
+ "show_waypoints": [bool, "KMZ File", "Show waypoints", False],
+ "order": [str, "KMZ File", "Order", "D"],
+ "image_size": [int, "KMZ File", "Pixels", 200],
++ "icon_size": [int, "KMZ File", "Icon pixels", 0],
+ "title": [str, "KMZ File", "Title", "Photo report"],
+- "clickable": [bool, "KMZ File", "Clickable", False]
++ "clickable": [bool, "KMZ File", "Clickable", False],
++ "url": [str, "KMZ File", "Photos URL", ""]
+ }
+
+ def __init__(self):
+@@ -133,7 +135,7 @@
+ if (type(value) == self.map[option][0]):
+ self.values[option] = value
+ else:
+- raise TypeError, "Expected %s, but got %s instead" % (self.map[options][0], type(value))
++ raise TypeError, "Expected %s, but got %s instead for option %s" % (self.map[option][0], type(value), option)
+ else:
+ raise UnknownOptionError(option)
+
+diff -dPNur happycamel-v1-beta3/HappyCamel/kmlhandler.py happycamel-v1-beta3-ds/HappyCamel/kmlhandler.py
+--- happycamel-v1-beta3/HappyCamel/kmlhandler.py 2008-04-17 21:25:10.000000000 +0200
++++ happycamel-v1-beta3-ds/HappyCamel/kmlhandler.py 2008-11-19 13:57:31.000000000 +0100
+@@ -27,7 +27,7 @@
+ def __init__(self, gpx_files, photo_list, thumbnail_names, logger,
+ title = "Photo report", track_color = "ffffffff",
+ track_width = 1.0, between_tracks_color = None,
+- between_tracks_width = None, photos_clickable = False):
++ between_tracks_width = None, photos_clickable = False, photos_url = "", use_icons = False):
+ """ Initialize a new KML file. gpx_files is a list of GPXFile objects which
+ should be drawn in the file. photo_list is a PhotoList object of
+ photo's whose thumbnail should be included. thumbnail_names is an
+@@ -43,6 +43,8 @@
+ self.thumbnail_names = thumbnail_names
+ self.title = title
+ self.photos_clickable = photos_clickable
++ self.photos_url = photos_url
++ self.use_icons = use_icons
+
+ # Check if the specified track colors and widths are ok
+ self.track_color = self.__testColorFormat__(track_color)
+@@ -117,11 +119,28 @@
+ for photo in self.photo_list:
+ if (photo in self.thumbnail_names): # Only process if there's a thumbnail
+ location = photo.getLocation()
++
++ if (self.use_icons):
++ out_fp.write(' <Style id="photo_%s">\n' % self.thumbnail_names[photo])
++ out_fp.write(' <IconStyle>\n')
++ out_fp.write(' <scale>1.5</scale>\n')
++ out_fp.write(' <Icon>\n')
++ out_fp.write(' <href>icons/%s</href>\n' % self.thumbnail_names[photo])
++ out_fp.write(' </Icon>\n')
++ out_fp.write(' </IconStyle>\n')
++ out_fp.write(' <LabelStyle>\n')
++ out_fp.write(' <scale>0.2</scale>\n')
++ out_fp.write(' </LabelStyle>\n')
++ out_fp.write(' </Style>\n')
++
+ out_fp.write(' <Placemark>\n')
+ out_fp.write(' <name>%s</name>\n' % photo.getName())
+ out_fp.write(' <description><![CDATA[')
+ if (self.photos_clickable):
+- out_fp.write('<a href="%s">' % photo.getURL())
++ if (self.photos_url):
++ out_fp.write('<a href="%s/%s">' % (self.photos_url, photo.getName()))
++ else:
++ out_fp.write('<a href="%s">' % photo.getURL())
+ out_fp.write('<img src="images/%s" />' % self.thumbnail_names[photo])
+ if (self.photos_clickable):
+ out_fp.write("</a>")
+@@ -136,7 +155,11 @@
+ out_fp.write(' <Snippet><![CDATA[%s]]></Snippet>\n' % comment)
+ else:
+ out_fp.write(' <Snippet>%s</Snippet>\n' % photo.getName())
+- out_fp.write(' <styleUrl>#photo_mark</styleUrl>\n')
++
++ if (self.use_icons):
++ out_fp.write(' <styleUrl>#photo_%s</styleUrl>\n' % self.thumbnail_names[photo])
++ else:
++ out_fp.write(' <styleUrl>#photo_mark</styleUrl>\n')
+ out_fp.write(' <Point>\n')
+ if (location[2]):
+ out_fp.write(' <altitudeMode>clampToGround</altitudeMode>\n')
+@@ -275,10 +298,10 @@
+ NUM_THUMBNAILS = 25
+
+ def __init__(self, file_name, logger, gpx_files = None, photo_list = None,
+- sort_order = "D", thumbnail_size = 200, title = "Photo report",
++ sort_order = "D", thumbnail_size = 200, icon_size = 0, title = "Photo report",
+ track_color = "ffffffff", track_width = 1.0,
+ between_tracks_color = None, between_tracks_width = None,
+- photos_clickable = False):
++ photos_clickable = False, photos_url = ""):
+ """ Create a new KMZ file with the disk path file_name. gpx_files is a list
+ of GPXFile objects that need to be showed in the file. photo_list is a
+ PhotoList object of photo's whose thumbnail should be included.
+@@ -286,8 +309,9 @@
+ presented ("D" is date and time, "A" is latitude, "O" is longitude.
+ Lowercase means reverse sort. Multiple tokens may be specified in order
+ of precedence).
+- thumbnail_size is the number of pixels the long size of each thumbnail
+- should have.
++ thumbnail_size is the number of pixels the long size of each thumbnail
++ should have.
++ icon_size is the number of pixels the long size of each icon should have.
+ title is the title given to the report in Google Earth.
+ track_color and between_tracks_color specify the color to give the
+ tracks and the lines in between the tracks, respectively. They are
+@@ -309,12 +333,14 @@
+ self.gpx_files = gpx_files
+ self.photo_list = photo_list
+ self.thumbnail_size = thumbnail_size
++ self.icon_size = icon_size
+ self.title = title
+ self.track_width = track_width
+ self.track_color = track_color
+ self.between_tracks_width = between_tracks_width
+ self.between_tracks_color = between_tracks_color
+ self.photos_clickable = photos_clickable
++ self.photos_url = photos_url
+
+ # Sort the photo's
+ for index in range(len(sort_order)):
+@@ -366,7 +392,9 @@
+ file_names[photo] = "%s.jpg" % fn_base
+
+ # Write the file
+- zip_file.writestr("images/%s.jpg" % fn_base, data)
++ zip_file.writestr("images/%s.jpg" % fn_base, data[0])
++ if (data[1]):
++ zip_file.writestr("icons/%s.jpg" % fn_base, data[1])
+ else:
+ self.logger.error("Couldn't make a thumbnail of image %s." % photo.getName())
+
+@@ -391,7 +419,7 @@
+ # but we put it here in a separate thread here as well because at the same
+ # time we need to start the processing thread.
+ get_thread = threading.Thread(target = self.photo_list.getThumbnailData,
+- args = [self.thumbnail_size, tn_queue])
++ args = [self.thumbnail_size, self.icon_size, tn_queue])
+ file_names = {}
+ process_thread = threading.Thread(target = self.__processThumbnails__,
+ args = [tn_queue, out_file, file_names])
+@@ -410,7 +438,7 @@
+ kml = KML(self.gpx_files, self.photo_list, file_names, self.logger,
+ self.title, self.track_color, self.track_width,
+ self.between_tracks_color, self.between_tracks_width,
+- self.photos_clickable)
++ self.photos_clickable, self.photos_url, bool(self.icon_size))
+ kml_fp = StringIO.StringIO()
+ kml.writeKML(kml_fp, write_photos, write_waypoints, write_track, write_between_tracks)
+
+diff -dPNur happycamel-v1-beta3/HappyCamel/main.py happycamel-v1-beta3-ds/HappyCamel/main.py
+--- happycamel-v1-beta3/HappyCamel/main.py 2008-04-17 21:25:10.000000000 +0200
++++ happycamel-v1-beta3-ds/HappyCamel/main.py 2008-11-19 14:22:55.000000000 +0100
+@@ -254,12 +254,14 @@
+ self.writeKMZFile(self.geo_sources.getAllGPXFiles(), photo_list,
+ kmz_file, self.conf.get("order"),
+ self.conf.get("image_size"),
++ self.conf.get("icon_size"),
+ self.conf.get("title"),
+ self.conf.get("track_color"),
+ self.conf.get("track_width"),
+ self.conf.get("between_color"),
+ self.conf.get("between_width"),
+ self.conf.get("clickable"),
++ self.conf.get("url"),
+ self.conf.get("show_waypoints"),
+ self.conf.get("show_track"),
+ self.conf.get("show_between_tracks"))
+@@ -525,16 +527,16 @@
+ if not (results[photo]):
+ self.logger.message("Couldn't succesfully write metadata to photo %s." % photo.getName())
+
+- def writeKMZFile(self, gpx_files, photo_list, file_path, order, image_size,
++ def writeKMZFile(self, gpx_files, photo_list, file_path, order, image_size, icon_size,
+ title, track_color, track_width, between_color,
+- between_width, clickable, show_waypoints, show_track,
++ between_width, clickable, photos_url, show_waypoints, show_track,
+ show_between_tracks):
+
+ """ Write the KMZ file with the specified options. """
+
+ kmz = kmlhandler.KMZ(file_path, self.logger, gpx_files,
+- photo_list, order, image_size, title, track_color,
+- track_width, between_color, between_width, clickable)
++ photo_list, order, image_size, icon_size, title, track_color,
++ track_width, between_color, between_width, clickable, photos_url)
+
+ kmz.writeFile(write_photos = True,
+ write_waypoints = show_waypoints, write_track = show_track,
+diff -dPNur happycamel-v1-beta3/HappyCamel/photohandler.py happycamel-v1-beta3-ds/HappyCamel/photohandler.py
+--- happycamel-v1-beta3/HappyCamel/photohandler.py 2008-04-17 21:25:10.000000000 +0200
++++ happycamel-v1-beta3-ds/HappyCamel/photohandler.py 2008-11-19 14:22:55.000000000 +0100
+@@ -164,7 +164,7 @@
+ if ((not self.ele) or overwrite):
+ self.ele = ele
+
+- def __scalePhoto__(self, file_obj, max_side):
++ def __scalePhoto__(self, file_obj, max_side, icon_size = 0):
+ """ Scale the photo referred to by the given file_obj so that the longest
+ size is max_side. If the original is smaller than the required format,
+ it isn't scaled. Return a JPEG-encoded string with data. """
+@@ -195,7 +195,24 @@
+ self.logger.debug("Required thumbnail for %s is larger than the original - no scaling." % self.getName())
+
+ # Return a JPEG encoded string
+- return photo_data.tostring("jpeg", "RGB")
++ thumbnail = photo_data.tostring("jpeg", "RGB")
++
++ if (icon_size):
++ if (photo_size[0] > photo_size[1]):
++ fraction = float(icon_size) / photo_size[0]
++ else:
++ fraction = float(icon_size) / photo_size[1]
++
++ if (fraction < 1.0):
++ icon_size = [int(photo_size[0] * fraction), int(photo_size[1] * fraction)]
++ self.logger.debug("Resizing thumnail %s from %dx%d to %dx%d pixels." % (self.getName(), thumbnail_size[0], thumbnail_size[1], icon_size[0], icon_size[1]))
++ photo_data.thumbnail(icon_size, Image.BICUBIC)
++
++ icon = photo_data.tostring("jpeg", "RGB")
++ else:
++ icon = None
++
++ return thumbnail, icon
+
+ return False
+
+@@ -543,7 +560,7 @@
+ results.update(self.__queue2Dict__(flickr_results))
+ return results
+
+- def getThumbnailData(self, max_side, queue):
++ def getThumbnailData(self, max_side, icon_size, queue):
+ """ Load all the thumbnails from the images in the list and put a tuple of
+ (photo object, JPEG-encoded thumbnail data) in the provided Queue.queue
+ instance. This allows for a multithreaded processing of the images.
+@@ -558,9 +575,9 @@
+
+ # Process the pools
+ self.__runThreaded__(self.DISK_THREAD_NUM, "getThumbnailData",
+- pools["disk"], queue, max_side = max_side)
++ pools["disk"], queue, max_side = max_side, icon_size = icon_size)
+ self.__runThreaded__(self.FLICKR_THREAD_NUM, "getThumbnailData",
+- pools["flickr"], queue, max_side = max_side)
++ pools["flickr"], queue, max_side = max_side, icon_size = icon_size)
+
+ def cleanup(self, check_date = False, check_location = False):
+ """ Removes the photos from the list which don't comply to the specified
+@@ -757,7 +774,7 @@
+
+ return "file://%s" % os.path.join(os.getcwd(), self.getPath())
+
+- def getThumbnailData(self, max_side = 200):
++ def getThumbnailData(self, max_side = 200, icon_size = 0):
+ """ Convert the image to a thumbnail and return the data, JPEG-encoded,
+ or False if we cannot convert this image. max_side specifies the number
+ of pixels the long side of the thumbnail needs to have. """
+@@ -767,7 +784,7 @@
+ if (ext in PIL_READ_FORMATS):
+ self.logger.debug("Creating thumbnail for photo %s" % self.getName())
+ photo_data = open(self.getPath())
+- return self.__scalePhoto__(photo_data, max_side)
++ return self.__scalePhoto__(photo_data, max_side, icon_size)
+ else:
+ self.logger.error("Can't create thumbnail for photo %s" % self.getName())
+ return False
+@@ -1270,7 +1287,7 @@
+
+ return True
+
+- def getThumbnailData(self, max_side = 200):
++ def getThumbnailData(self, max_side = 200, icon_size = 0):
+ """ Convert the image to a thumbnail and return the data, JPEG-encoded,
+ or False if we cannot convert this image. max_side specifies the number
+ of pixels the long side of the thumbnail needs to have. """
+@@ -1312,7 +1329,7 @@
+
+ # Download the photo and load it as a PIL image
+ photo_data = StringIO.StringIO(urllib2.urlopen(best_fit["entry"]["source"]).read())
+- return self.__scalePhoto__(photo_data, max_side)
++ return self.__scalePhoto__(photo_data, max_side, icon_size)
+
+ def writeMetadata(self, write_coords = True, write_geo_names = False,
+ correct_time = False):