[Bugs] #4470 Record UNSP: Record: Don't save preview encoded

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Wed Mar 20 08:57:07 EDT 2013


#4470: Record: Don't save preview encoded
------------------------------------------+---------------------------------
    Reporter:  godiard                    |          Owner:  dsd        
        Type:  defect                     |         Status:  new        
    Priority:  Unspecified by Maintainer  |      Milestone:  0.98       
   Component:  Record                     |        Version:  Unspecified
    Severity:  Unspecified                |       Keywords:             
Distribution:  Unspecified                |   Status_field:  Unconfirmed
------------------------------------------+---------------------------------
 The preview in the journal metadata should not be saved encoded, in first
 place because need more space, in second place, in sugar
 jarabe/journal/expandedentry.py line 215 we have:

 {{{
             if self._metadata['preview'][1:4] == 'PNG':
                 preview_data = self._metadata['preview']
             else:
                 # TODO: We are close to be able to drop this.
                 import base64
                 preview_data = base64.b64decode(
                         self._metadata['preview'])
 }}}

 Finally, having some previews encoded and other not, makes more difficult
 the work of other activities using the preview, like Portfolio or the new
 activity to share the journal content.

 The problem space is in part due to the encoding, but also due to the need
 of save the preview in png format. In fact the preview is a lot bigger
 than the photo. To test it you can take a photo in record and put a title
 (in this case "mano"). After exit the activity do:

 {{{
 [olpc at xo-a7-32-6d ~]$ cd .sugar/default/datastore/

 [olpc at xo-a7-32-6d datastore]$ grep -r mano */*/metadata/*
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/metadata/title:mano

 [olpc at xo-a7-32-6d datastore]$ ls -l
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/metadata/preview
 -rw-r--r-- 1 olpc olpc 143348 mar 20 11:19 preview

 [olpc at xo-a7-32-6d datastore]$ ls -l
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/data
 -r--r--r-- 1 olpc olpc 37873 mar 20 11:19
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/data

 [olpc at xo-a7-32-6d datastore]$ file
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/metadata/preview
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/metadata/preview: ASCII text, with
 very long lines, with no line terminators

 [olpc at xo-a7-32-6d datastore]$ file
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/data
 5b/5b1430b7-f128-4845-a0a4-baac8b5ccf9e/data: JPEG image data, JFIF
 standard 1.01
 }}}

 (the preview is 5 times bigger than the photo)

 To compare, do the same with Paint activity:

 {{{
 [olpc at xo-a7-32-6d datastore]$ grep -r dibujo */*/metadata/*
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/metadata/title:dibujo

 [olpc at xo-a7-32-6d datastore]$ ls -l
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/metadata/preview
 -rw-r--r-- 1 olpc olpc 8645 mar 20 11:33 preview

 [olpc at xo-a7-32-6d datastore]$ ls -l
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/data
 -rw-r--r-- 1 olpc olpc 50046 mar 20 11:33
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/data

 [olpc at xo-a7-32-6d datastore]$ file
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/data
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/data: PNG image data, 1200 x 825,
 8-bit/color RGB, non-interlaced

 [olpc at xo-a7-32-6d datastore]$ file
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/metadata/preview
 c3/c3d6ea61-baf6-4065-bac0-ebec5e4fff7c/metadata/preview: PNG image data,
 300 x 225, 8-bit/color RGBA, non-interlaced
 }}}

 The preview is a PNG file, and is 5 times smaller than the draw.

 After the patch, the preview is saved as a png and you can see the preview
 is a little smaller:

 {{{
 [olpc at xo-a7-32-6d datastore]$ grep -r hand */*/metadata/*
 9d/9d8b6a6e-ea8b-4e17-bac2-cdc0363d6ba0/metadata/title:hand

 [olpc at xo-a7-32-6d datastore]$ ls -l 9d/9d8b6a6e-ea8b-
 4e17-bac2-cdc0363d6ba0/metadata/preview
 -rw-r--r-- 1 olpc olpc 99717 mar 20 11:57 preview

 [olpc at xo-a7-32-6d datastore]$ ls -l 9d/9d8b6a6e-ea8b-
 4e17-bac2-cdc0363d6ba0/data
 -r--r--r-- 1 olpc olpc 36714 mar 20 11:57 9d/9d8b6a6e-ea8b-
 4e17-bac2-cdc0363d6ba0/data

 [olpc at xo-a7-32-6d datastore]$ file  9d/9d8b6a6e-ea8b-
 4e17-bac2-cdc0363d6ba0/metadata/preview
 9d/9d8b6a6e-ea8b-4e17-bac2-cdc0363d6ba0/metadata/preview: PNG image data,
 300 x 225, 8-bit/color RGB, non-interlaced

 [olpc at xo-a7-32-6d datastore]$ file 9d/9d8b6a6e-ea8b-
 4e17-bac2-cdc0363d6ba0/data
 9d/9d8b6a6e-ea8b-4e17-bac2-cdc0363d6ba0/data: JPEG image data, JFIF
 standard 1.01
 }}}

 We could save more space using jpeg as a format, but we need update the
 code in expandedentry.py to load any file format. Is easy to do, if we
 evaluate worth it, can be done, see [1]

 Saving in jpeg format:

 {{{
 [olpc at xo-a7-32-6d datastore]$ grep -r jpeg-hand */*/metadata/*
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/metadata/title:jpeg-hand

 [olpc at xo-a7-32-6d datastore]$ ls -l
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/metadata/preview
 -rw-r--r-- 1 olpc olpc 13361 mar 20 12:07 preview

 [olpc at xo-a7-32-6d datastore]$ file
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/metadata/preview
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/metadata/preview: JPEG image data,
 JFIF standard 1.01

 [olpc at xo-a7-32-6d datastore]$ ls -l
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/data
 -r--r--r-- 1 olpc olpc 59600 mar 20 12:07
 a1/a187a2e3-e1a5-4be4-9c76-b9d3f346a523/data
 }}}

 [1]
 https://git.sugarlabs.org/paint/mainline/commit/16495674277dfed5241d0bf6711d475765e731a8

-- 
Ticket URL: <http://bugs.sugarlabs.org/ticket/4470>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list