Page 1 of 1

label:@filename not working

Posted: 2018-01-03T15:42:04-07:00
by kaleb
I'm using Version: ImageMagick 6.9.7-4 Q16 arm

I have been trying to use label:@filename and I am unable to get it to work. I am a complete "newbie" with ImageMagick so I have been using the examples on https://www.imagemagick.org/Usage/text/ as a starting point. All was going well until I tried the example:

Code: Select all

convert -background lightblue  -fill blue \
          label:@/etc/test   label_file.gif
The label_file.giff simply used the @/etc/motd as the label text and did not read it from my file "test"

I changed the policy.xml file to remove the line

<policy domain="path" rights="none" pattern="@*"/>

This has not resolved the problem.
I then tried

<policy domain="path" rights="all" pattern="@*"/>

This did not help either.
Has anyone any idea what I'm doing wrong?

Re: label:@filename not working

Posted: 2018-01-03T16:25:39-07:00
by fmw42
This works fine for me on IM 6.9.7.4 and 6.9.9.29 Q16 Mac OSX Sierra with no change to my policy.xml file.

Code: Select all

convert -background lightblue  -fill blue label:@test  label_file.gif
Try placing the file in another directory. Perhaps you have no permissions to read from /etc

Code: Select all

<policymap>
  <!-- <policy domain="system" name="shred" value="2"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <!-- <policy domain="system" name="memory-map" value="anonymous"/> -->
  <!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <!-- <policy domain="resource" name="memory" value="2GiB"/> -->
  <!-- <policy domain="resource" name="map" value="4GiB"/> -->
  <!-- <policy domain="resource" name="width" value="10KP"/> -->
  <!-- <policy domain="resource" name="height" value="10KP"/> -->
  <!-- <policy domain="resource" name="area" value="100MP"/> -->
  <!-- <policy domain="resource" name="disk" value="16EiB"/> -->
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
  <!-- <policy domain="delegate" rights="none" pattern="HTTPS" /> -->
  <!-- <policy domain="path" rights="none" pattern="@*" /> -->
  <!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->
  <!-- <policy domain="cache" name="synchronize" value="True"/> -->
  <!-- <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/> -->
</policymap>
If that does not help, then uncomment the line and change the rights

from

Code: Select all

  <!-- <policy domain="path" rights="none" pattern="@*" /> -->
To

Code: Select all

<policy domain="path" rights="read" pattern="@*" />
(or all)

My policy.xml file is at /usr/local/etc/ImageMagick-6/policy.xml

Re: label:@filename not working

Posted: 2018-01-03T16:34:26-07:00
by fmw42
P.S. Do you have an up to date Freetype delegate library installed. Mine is freetype @2.8_0

Also try specifying a font or path to a font file in your command.

Re: label:@filename not working

Posted: 2018-01-04T04:45:59-07:00
by kaleb
Thanks for your help. I have tried changing the permissions to "read" but still the @ does not seem to be parsed and is simply printed as part of the label together with the file name.

I have changed my code to include fonts etc and also made sure my text file ("Test") has all permissions set to "Anyone". The containing folder "pi" has permissions set for access as "Anyone".I have included the path of the text file. I don't think this is the problem.

My current code is:

Code: Select all

convert -background lightblue  -fill blue -font NewCenturySchlbk-BoldItalic -size 696x271  -pointsize 48  -gravity center            label:@/home/pi/test  label_file.png
This produces the png file with the correct font, size and colors but the text is: @/home/pi/test

The @ symbol is not being interpreted by ImageMagick as an instruction but being used directly as the label.

I wanted to use a named pipe to pass data but without geting this to work I am at a loss as to how to go further.

Re: label:@filename not working

Posted: 2018-01-04T05:23:47-07:00
by Bonzo
What operating system are you using?

Re: label:@filename not working

Posted: 2018-01-04T05:46:12-07:00
by kaleb
I'm using ImageMagick on a Raspberry Pi operating on Raspbian (Debian Linux)

Re: label:@filename not working

Posted: 2018-01-04T10:22:12-07:00
by fmw42
Can you update your ImageMagick? Did you check your version of Freetype?

Can you post your policy.xml file and tell us the directory from which you are getting it?

Re: label:@filename not working

Posted: 2018-01-04T16:34:13-07:00
by kaleb
I'm not sure how to check Freetype version.
I have run update and the version I am using ( 6.9.7-4) is the latest available on my platform.
( @ Policy Modified to "Read" but I have tried "All" and deleting this policy) Policy currently is as follows:

Path: /etc/ImageMagick-6/policy.xml
Policy: Resource
name: disk
value: 1GiB
Policy: Resource
name: map
value: 512MiB
Policy: Resource
name: memory
value: 256MiB
Policy: Resource
name: area
value: 128MB
Policy: Resource
name: height
value: 16KP
Policy: Resource
name: width
value: 16KP
Policy: Delegate
rights: None
pattern: URL
Policy: Delegate
rights: None
pattern: HTTPS
Policy: Delegate
rights: None
pattern: HTTP
Policy: Path
rights: Read
pattern: @*

Path: [built-in]
Policy: Undefined
rights: None

Re: label:@filename not working

Posted: 2018-01-04T16:56:08-07:00
by fmw42
Your policy.xml file looks strange and is not what I get. Version 6.9.7.4 is about 55 versions old.

My policy.xml file at /usr/local/etc/ImageMagick-6/policy.xml is:

Code: Select all

<policymap>
  <!-- <policy domain="system" name="shred" value="2"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <!-- <policy domain="system" name="memory-map" value="anonymous"/> -->
  <!-- <policy domain="system" name="max-memory-request" value="256MiB"/> -->
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <!-- <policy domain="resource" name="memory" value="2GiB"/> -->
  <!-- <policy domain="resource" name="map" value="4GiB"/> -->
  <!-- <policy domain="resource" name="width" value="10KP"/> -->
  <!-- <policy domain="resource" name="height" value="10KP"/> -->
  <!-- <policy domain="resource" name="area" value="100MP"/> -->
  <!-- <policy domain="resource" name="disk" value="16EiB"/> -->
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
  <!-- <policy domain="delegate" rights="none" pattern="HTTPS" /> -->
  <!-- <policy domain="path" rights="none" pattern="@*" /> -->
  <!-- <policy domain="cache" name="memory-map" value="anonymous"/> -->
  <!-- <policy domain="cache" name="synchronize" value="True"/> -->
  <!-- <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/> -->
</policymap>
You say your policy.xml is at /etc/ImageMagick-6/policy.xml. Perhaps it should be /usr/local/etc/ImageMagick-6/policy.xml. Did you actually install IM in /etc. I think that is an improper location or a mistake.

Do you have policy.xml file in different locations? Yours is different from mine. That can happen and there is a precedence for which one is used over other ones. See http://legacy.imagemagick.org/script/resources.php for the list of locations and order used.

Under Unix and Linux, ImageMagick searches for each of the configuration files ... by looking in the locations given below, in order, and loads them if found:

$MAGICK_CONFIGURE_PATH
$PREFIX/etc/ImageMagick-6
$PREFIX/share/ImageMagick-6
$XDG_CACHE_HOME/ImageMagick
$HOME/.config/ImageMagick
<client path>/etc/ImageMagick

On unix, you can find the list of policy.xml files by

Code: Select all

find /usr -name policy.xml

Re: label:@filename not working

Posted: 2018-01-04T17:20:43-07:00
by kaleb
Sorry that was the policy as reported after a querry ie $ convert -list policy

The actual policy xml file is

Code: Select all

>
<policymap>
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <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"/>
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <!-- not needed due to the need to use explicitly by mvg: -->
  <!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
  <!-- use curl -->
  <policy domain="delegate" rights="none" pattern="URL" />
  <policy domain="delegate" rights="none" pattern="HTTPS" />
  <policy domain="delegate" rights="none" pattern="HTTP" />
  <!-- in order to avoid to get image with password text -->
  <policy domain="path" rights="read" pattern="@*"/> 
  <policy domain="cache" name="shared-secret" value="passphrase" stealth="true"/>
</policymap>

Re: label:@filename not working

Posted: 2018-01-04T17:24:23-07:00
by fmw42
It looks OK to me. What is the location? Do you have more than one location with policy.xml?

Re: label:@filename not working

Posted: 2018-01-04T18:05:09-07:00
by kaleb
This is the latest version available for the Raspberry pi. I stress again that Imagemagick works perfectly well in all respects other than not correctly using the @filename function; not parsing the @ but just printing "@filename" using both caption and label. I don't believe it would work at all if the paths were incorrect.

I have tried piping the keyboard and this works using @-

Code: Select all

cat   | convert label:@-   pipe_test.gif
I type at the keyboard and the pipe_test.gif file contains the text I type, just as expected.

But I can't get the @ to substitute a text file eg

Code: Select all

convert label:@/etc/mytextfile   test.gif
The freetype version is 2.6.3-3.2 and again this is the latest version available for the Raspberry pi.

Re: label:@filename not working

Posted: 2018-01-04T20:12:49-07:00
by fmw42
Mine is freetype @2.8_0, but I doubt that is the issue. I still think it is trying to get data from /etc. Can you try accessing a local file to the directory where you issue the command and also put .txt as the suffix. Without the suffix, perhaps IM or your file system does not know that it is a text file. See if either of those work.

I tried your command in IM 6.9.7.4 Q16 Mac OSX Sierra as follows and it works fine.

Code: Select all

convert -background lightblue  -fill blue label:@test.txt label_file.gif
where the file test.txt is in the same directory where I issue the command.

It also works with quotes as follows:

Code: Select all

convert -background lightblue  -fill blue label:"@test.txt" label_file.gif

Re: label:@filename not working

Posted: 2018-01-05T03:14:34-07:00
by kaleb
PROBLEM SOLVED!
You are quite right! If I move the file to root it works, with or without the .txt suffix. Now I have just got to work out why! It would seem that if ImageMagick can't find a file it ignores the @ directive and simply prints the @ and file name. Thank you for your help.