Commit 5c111888 authored by Romain Courteaud's avatar Romain Courteaud

Cache text conversion of image.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24495 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7e049833
...@@ -304,13 +304,11 @@ class Image(File, OFSImage): ...@@ -304,13 +304,11 @@ class Image(File, OFSImage):
return displays return displays
# Conversion API security.declarePrivate('_convertToText')
security.declareProtected(Permissions.ModifyPortalContent, 'convert') def _convertToText(self, format):
def convert(self, format, display=None, quality=75, resolution=None, frame=None, **kw):
""" """
Implementation of conversion for PDF files Convert the image to text with portaltransforms
""" """
if format in ('text', 'txt', 'html', 'base_html', 'stripped-html'):
mime_type = getToolByName(self, 'mimetypes_registry').\ mime_type = getToolByName(self, 'mimetypes_registry').\
lookupExtension('name.%s' % format) lookupExtension('name.%s' % format)
src_mimetype = self.getContentType() src_mimetype = self.getContentType()
...@@ -330,6 +328,18 @@ class Image(File, OFSImage): ...@@ -330,6 +328,18 @@ class Image(File, OFSImage):
else: else:
# text_content is not set, return empty string instead of None # text_content is not set, return empty string instead of None
return mime_type, '' return mime_type, ''
# Conversion API
security.declareProtected(Permissions.ModifyPortalContent, 'convert')
def convert(self, format, display=None, quality=75, resolution=None, frame=None, **kw):
"""
Implementation of conversion for PDF files
"""
if format in ('text', 'txt', 'html', 'base_html', 'stripped-html'):
if not self.hasConversion(format=format):
mime_type, data = self._convertToText(format)
self.setConversion(data, mime=mime_type, format=format)
return self.getConversion(format=format)
image_size = self.getSizeFromImageDisplay(display) image_size = self.getSizeFromImageDisplay(display)
if (display is not None or resolution is not None or quality != 75 or format != ''\ if (display is not None or resolution is not None or quality != 75 or format != ''\
or frame is not None) and image_size: or frame is not None) and image_size:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment