Fix thumbnail creating

This commit is contained in:
Tomas Groth 2014-09-10 22:30:32 +01:00
parent 489f2266b2
commit cf351a7af9
5 changed files with 8 additions and 8 deletions

View File

@ -280,7 +280,7 @@ class ImageManager(QtCore.QObject):
"""
Add image to cache if it is not already there.
"""
log.debug('add_image %s' % path)
log.debug('add_image path: %s, source: %s, width: %d, height: %d ' % (path, source, width, height))
if not (path, source, width, height) in self._cache:
image = Image(path, source, background, width, height)
self._cache[(path, source, width, height)] = image

View File

@ -302,7 +302,8 @@ class ServiceItem(RegistryProperties):
thumbnail = os.path.join(AppLocation.get_section_data_path('images'), 'thumbnails', os.path.split(path)[1])
create_thumb(path, thumbnail, False)
self._raw_frames.append({'title': title, 'path': path, 'image': thumbnail})
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border)
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border, 88, 88)
self.image_manager.add_image(thumbnail, ImageSource.ImagePlugin, self.image_border, 320, 240)
self.image_manager.add_image(path, ImageSource.ImagePlugin, self.image_border)
self._new_item()

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.common import Registry, AppLocation, Settings, UiStrings, check_directory_exists, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem, ServiceItemContext, StringContent, TreeWidgetWithDnD,\
build_icon, check_item_selected, create_thumb, validate_thumb
build_icon, check_item_selected, create_thumb, validate_thumb, ImageSource
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
from openlp.core.utils import delete_file, get_locale_key, get_images_filter
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm
@ -590,7 +590,7 @@ class ImageMediaItem(MediaManagerItem):
# Continue with the existing images.
for filename in images_file_names:
name = os.path.split(filename)[1]
service_item.add_from_image(filename, name, background, os.path.join(self.service_path, name))
service_item.add_from_image(filename, ImageSource.ImagePlugin, background, os.path.join(self.service_path, name))
return True
def check_group_exists(self, new_group):

View File

@ -99,7 +99,7 @@ window.OpenLP = {
text += ("<div style='font-size:smaller;font-weight:normal'>" + slide["notes"] + "</div>");
text = text.replace(/\n/g, '<br />');
if (slide["img"])
text += "<img src='" + slide["img"].replace("/thumbnails/", "/thumbnails80x80/") + "'>";
text += "<img src='" + slide["img"].replace("/thumbnails/", "/thumbnails88x88/") + "'>";
var li = $("<li data-icon=\"false\">").append(
$("<a href=\"#\">").html(text));
if (slide["selected"]) {

View File

@ -125,7 +125,7 @@ from mako.template import Template
from PyQt4 import QtCore
from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate
from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities
from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities, ImageSource
log = logging.getLogger(__name__)
FILE_TYPES = {
@ -406,9 +406,8 @@ class HttpRouter(RegistryProperties):
full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name),
'thumbnails/' + full_path))
if os.path.exists(full_path):
path, just_file_name = os.path.split(full_path)
ext, content_type = self.get_content_type(full_path)
image = self.image_manager.get_image(full_path, just_file_name, width, height)
image = self.image_manager.get_image(full_path, ImageSource.ImagePlugin , width, height)
content = image_to_byte(image, False)
if len(content) == 0:
return self.do_not_found()