Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory for imagemagick #5

Open
ukos-git opened this issue Jul 1, 2018 · 1 comment
Open

memory for imagemagick #5

ukos-git opened this issue Jul 1, 2018 · 1 comment

Comments

@ukos-git
Copy link
Contributor

ukos-git commented Jul 1, 2018

I ran into memory issues when using scaling factor 4:

montage-im6.q16: DistributedPixelCache '127.0.0.1' @ error/distribute-cache.c/ConnectPixelCacheServer/244.
montage-im6.q16: cache resources exhausted `assembled/background_4.png' @ error/cache.c/OpenPixelCache/3984.
montage-im6.q16: too many exceptions (exception processing suspended).
Traceback (most recent call last):
  File "extract_metabol.py", line 95, in <module>
    tempimg = Image.open(filename)
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2590, in open
    % (filename if filename else fp))
OSError: cannot identify image file 'assembled/background_4.png'

I had to update imagemagick configuration file according to this issue:

diff /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.lowres 
53,58c53,58
<   <policy domain="resource" name="memory" value="4GiB"/>
<   <policy domain="resource" name="map" value="8GiB"/>
<   <policy domain="resource" name="width" value="256KP"/>
<   <policy domain="resource" name="height" value="256KP"/>
<   <policy domain="resource" name="area" value="2GP"/>
<   <policy domain="resource" name="disk" value="16GiB"/>
---
>   <policy domain="resource" name="memory" value="256MiB"/>
>   <policy domain="resource" name="map" value="512MiB"/>
>   <policy domain="resource" name="width" value="16KP"/>
>   <policy domain="resource" name="height" value="16KP"/>
>   <policy domain="resource" name="area" value="128MB"/>
>   <policy domain="resource" name="disk" value="1GiB"/>

We could check for correct settings using grep at the beginning of the script, but to maintain OSX executability, we would also need to check for the current system.

on linux the file is /etc/ImageMagick-6/policy.xml
so we would use something like

memor="$(grep -e "name=\"memory\"" /etc/ImageMagick-6/policy.xml | sed -r 's/^.*value=\"([^\"]+)\".*$/\1/g')"

to get the current imagemagick memory limit using bash. Maybe a make script could simplifiy the job here.
What do you think?

@usnish
Copy link
Owner

usnish commented Aug 1, 2018

It's been quite a long while since I've looked at this code -- I think you're spot on re: the config file, and about writing a make script. Currently on clinical clerkships in medical school so extremely short on time, but if you want to take a crack definitely go for it!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants