Page 1 of 2

scale bar changes in pdf exported from figure

PostPosted: Thu Jan 17, 2019 6:49 pm
by jcopeland
Hello,

Users of OMERO.figure here at HMS have noticed that when they export a PDF produced by OMERO.figure that the scale bar changes by becoming longer than what was displayed in figure. I have attached a screenshot showing this. The scale bar in the PDF is approximately twice the length of the scale bar in figure. The original data is a big tiled image. I have been able to reproduce this error in other big tiled images but not regular microscope images. So it appears to be be a problem related big tiled images only.

Jay
Screen Shot 2019-01-17 at 1.47.56 PM.png
Screen Shot 2019-01-17 at 1.47.56 PM.png (239.21 KiB) Viewed 1582 times

Re: scale bar changes in pdf exported from figure

PostPosted: Sun Jan 20, 2019 7:57 am
by jburel
Hi Jay

Thanks for reporting the issue.
The problem should be fixed by https://github.com/ome/omero-figure/pull/304
and the fix available was included in figure 4.0.1.

Cheers

Jean-marie

Re: scale bar changes in pdf exported from figure

PostPosted: Wed Jan 23, 2019 6:58 pm
by jcopeland
Hello,

Thanks for the help. I have upgraded to figure 4.0.2. When attempting to export a PDF I get the following. Any suggestions?

Thanks.

Jay

Code: Select all
Traceback (most recent call last):
  File "./script", line 2128, in <module>
    run_script()
  File "./script", line 2114, in run_script
    file_annotation = export_figure(conn, script_params)
  File "./script", line 2070, in export_figure
    return fig_export.build_figure()
  File "./script", line 800, in build_figure
    self.add_panels_to_page(panels_json, image_ids, page)
  File "./script", line 1585, in add_panels_to_page
    image, pil_img = self.draw_panel(panel, page, i)
  File "./script", line 1416, in draw_panel
    self.paste_image(pil_img, img_name, panel, page, dpi)
  File "./script", line 1734, in paste_image
    self.figure_canvas.drawImage(img_name, x, y, width, height)
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/pdfgen/canvas.py", line 926, in drawImage
    imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/pdfbase/pdfdoc.py", line 2127, in __init__
    self.loadImageFromA85(src)
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/pdfbase/pdfdoc.py", line 2133, in loadImageFromA85
    imagedata = map(string.strip,pdfutils.makeA85Image(source,IMG=IMG))
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/pdfbase/pdfutils.py", line 34, in makeA85Image
    raw = img.getRGBData()
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/lib/utils.py", line 656, in getRGBData
    annotateException('\nidentity=%s'%self.identity())
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/reportlab/lib/utils.py", line 653, in getRGBData
    self._data = im.tostring()
  File "/data/omero-local/virtualenv/lib/python2.7/site-packages/PIL/Image.py", line 694, in tostring
    "Please call tobytes() instead.")
NotImplementedError: tostring() has been removed. Please call tobytes() instead.
identity=[ImageReader@0x7f7cd4ee1410 filename='0_con_yfpCENPEcrestdapi16_R3D.dv.tiff']

Re: scale bar changes in pdf exported from figure

PostPosted: Fri Jan 25, 2019 9:42 am
by jburel
Hi Jay
The error is due to the version of reportlab and Pillow you have installed on the server.
Which version do you have installed?
Depending on the version of Pillow, downgrading it will probably fix the issue triggered by reportlab.

Cheers

Jmarie

Re: scale bar changes in pdf exported from figure

PostPosted: Thu Jan 31, 2019 7:04 pm
by jmuhlich
Hi, Jay and I are still experiencing the scale bar length bug. I've tracked it down to situations where the DPI range set with the "Set DPI" button has a max DPI less than the "native" DPI of the panel, and the image itself is large (bigger than somewhere around 3000 x 3000 pixels, maybe?). This is why we notice it on very large histology images, since they're usually big enough that their native DPI without cropping is well over the default max DPI of 1000. However for smaller images, I can't get the bug to trigger even if I adjust the max DPI to meet the above criteria. I'm not sure what the cutoff is for "large" images that trigger the bug, but I do know that a 2800x2800 image was fine but a 3500x3500 one was not. Let me know if there's anything else I can explore to help diagnose this issue.

Re: scale bar changes in pdf exported from figure

PostPosted: Thu Jan 31, 2019 7:15 pm
by jmuhlich
Sorry, I should have started by saying that we did sort out the Python package version issues. Everything I described above was seen with Figure 4.0.2.

Re: scale bar changes in pdf exported from figure

PostPosted: Fri Feb 01, 2019 9:56 am
by mtbc
When you say you sorted out the Python package version issues: which versions of Pillow and reportlab do you now have installed, which have you tried? Maybe just paste a "pip freeze" output that might help us to reproduce at our end.

Cheers,
Mark

Re: scale bar changes in pdf exported from figure

PostPosted: Fri Feb 01, 2019 12:58 pm
by jcopeland
cycler==0.10.0
Cython==0.19.1
Django==1.8.19
django-pipeline==1.3.20
django-redis==4.8.0
django-redis-cache==1.7.1
futures==3.2.0
gunicorn==19.7.1
importlib==1.0.4
Markdown==3.0.1
matplotlib==1.5.1
numexpr==2.1
numpy==1.14.2
omero-cli-render==0.2.0.dev1
omero-figure==4.0.2
omero-iviewer==0.5.0
omero-marshal==0.5.2
pathviewer==2.1.1
Pillow==5.4.1
psycopg2==2.6.1
pyparsing==2.1.4
PyRSS2Gen==1.1
python-dateutil==2.5.3
python-memcached==1.57
pytz==2016.4
redis==2.10.6
reportlab==3.5.13
scipy==0.17.1
six==1.10.0
tables==2.4.0
virtualenv==15.0.1
zeroc-ice==3.6.4

Re: scale bar changes in pdf exported from figure

PostPosted: Mon Feb 04, 2019 9:28 am
by wmoore
Hi,

Sorry to hear the bug isn't fixed for you.

I'll try to reproduce it on images around 3500 x 3500 pixels in size.
To help this, could you give us:

- The pixel size x (e.g. in Microns or whatever units you have)
- The length of the scalebar you have added.
- The zoom level of the panel in figure (%)
- How the PDF scalebar is wrong (e.g. "it should be twice as long as it is")

A screenshot of the PDF (or the PDF itself would be even better) if you're happy to post it publicly

I tested this fix on a very big image (62 k x 60 k) by drawing ROIs of various lengths and exporting them alongside scalebars: https://github.com/ome/omero-figure/pull/304.

Thanks,

Will.

Re: scale bar changes in pdf exported from figure

PostPosted: Tue Feb 05, 2019 4:33 pm
by jcopeland
Screen Shot 2019-02-05 at 11.30.54 AM.png
screen shot of PDF. The ROI shows the size of the 500um scale bar approximately.
Screen Shot 2019-02-05 at 11.30.54 AM.png (35.14 KiB) Viewed 1365 times
wmoore wrote:To help this, could you give us:

- The pixel size x (e.g. in Microns or whatever units you have)
- The length of the scalebar you have added.
- The zoom level of the panel in figure (%)
- How the PDF scalebar is wrong (e.g. "it should be twice as long as it is")

A screenshot of the PDF (or the PDF itself would be even better) if you're happy to post it publicly


0.31x0.31um
500um
100%
About 4x too long on the PDF.