Error of Textcleaner @Synology

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
ulli
Posts: 4
Joined: 2016-06-29T10:33:03-07:00
Authentication code: 1151

Error of Textcleaner @Synology

Post by ulli »

Hello,

I am trying to get the Textcleander running but I always get the following error:

Code: Select all

2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: utility.c/ExpandFilenames/935/Configure
  Command line: convert {-debug} {all} {-respect-parenthesis} {(} {./textcleaner_1_30964.mpc} {-colorspace} {gray} {-type} {grayscale} {-contrast-stretch} {0} {)} {(} {-clone} {0} {-colorspace} {gray} {-negate} {-lat} {25x25+20%} {-contrast-stretch} {0} {-blur} {1x65535} {-level} {30x100%} {)} {-compose} {copy_opacity} {-composite} {-fill} {white} {-opaque} {none} {-alpha} {off} {-background} {white} {-deskew} {40%} {-sharpen} {0x1} {-trim} {+repage} {-compose} {over} {-bordercolor} {white} {-border} {20} {out.jpg}
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Policy convert[31030]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Read; pattern="./textcleaner_1_30964.mpc" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Blob convert[31030]: blob.c/OpenBlob/2590/Blob
    read 3 magic header bytes
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Cache convert[31030]: cache.c/DestroyPixelCache/991/Cache
  destroy 
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/opt/etc/ImageMagick-6/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/ImageMagick-6/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/lib/ImageMagick-6.9.1//config-Q8/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/bin/ImageMagick-6/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/usr/share/doc/ImageMagick-6/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/var/services/homes/admin/.config/ImageMagick/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: configure.c/GetConfigureOptions/679/Configure
  Searching for configure file: "/var/services/homes/admin/.magick/magic.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: magic.c/LoadMagicCache/773/Configure
  Loading magic configure file "/opt/etc/ImageMagick-6/magic.xml" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Policy convert[31030]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Coder; rights=Read; pattern="MPC" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Policy convert[31030]: policy.c/IsRightsAuthorized/574/Policy
  Domain: Path; rights=Read; pattern="./textcleaner_1_30964.mpc" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Blob convert[31030]: blob.c/OpenBlob/2590/Blob
    read 3 magic header bytes
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Width: 2.46KB/2.46KB/429.5MB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Height: 3.48KB/3.48KB/429.5MB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Area: 34.23MB/34.23MB/1.0473GB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Memory: 34.23MB/32.64MiB/499.4MiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Cache convert[31030]: cache.c/OpenPixelCache/3628/Cache
  open ./textcleaner_1_30964.mpc[0] (Heap Memory, 2456x3484 32.64MiB)
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Cache convert[31030]: cache.c/PersistPixelCache/3868/Cache
  attach persistent cache
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Width: 2.46KB/2.46KB/429.5MB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Height: 3.48KB/3.48KB/429.5MB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Area: 34.23MB/34.23MB/1.0473GB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Memory: 34.23MB/65.28MiB/499.4MiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/RelinquishMagickResource/1002/Resource
  Memory: 34.23MB/32.64MiB/499.4MiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/AcquireMagickResource/312/Resource
  Disk: 34.23MB/32.64MiB/16EiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/RelinquishMagickResource/1002/Resource
  Disk: 34.23MB/0B/16EiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/opt/etc/ImageMagick-6/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/share/ImageMagick-6/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/lib/ImageMagick-6.9.1//config-Q8/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/bin/ImageMagick-6/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/share/doc/ImageMagick-6/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/var/services/homes/admin/.config/ImageMagick/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/var/services/homes/admin/.magick/locale.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: locale.c/LoadLocaleCache/1176/Configure
  Loading locale configure file "/opt/etc/ImageMagick-6/locale.xml" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/opt/etc/ImageMagick-6/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/share/ImageMagick-6/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/lib/ImageMagick-6.9.1//config-Q8/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/bin/ImageMagick-6/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/usr/share/doc/ImageMagick-6/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/var/services/homes/admin/.config/ImageMagick/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Locale convert[31030]: locale.c/GetLocaleOptions/825/Locale
  Searching for locale file: "/var/services/homes/admin/.magick/english.xml"
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Configure convert[31030]: locale.c/LoadLocaleCache/1176/Configure
  Loading locale configure file "/opt/etc/ImageMagick-6/english.xml" ...
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Exception convert[31030]: cache.c/OpenPixelCache/3711/Exception
  unable to open pixel cache `./textcleaner_1_30964.mpc': No such file or directory
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Exception convert[31030]: mpc.c/ReadMPCImage/944/Exception
  unable to persist pixel cache `./textcleaner_1_30964.mpc'
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Cache convert[31030]: cache.c/DestroyPixelCache/991/Cache
  destroy ./textcleaner_1_30964.mpc[0]
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Resource convert[31030]: resource.c/RelinquishMagickResource/1002/Resource
  Disk: 34.23MB/16EiB/16EiB
2016-06-29T19:51:08+02:00 0:00.000 0.000u 6.9.1 Exception convert[31030]: convert.c/ConvertImageCommand/970/Exception
  image sequence is required `-clone'
convert: unable to open pixel cache `./textcleaner_1_30964.mpc': No such file or directory @ error/cache.c/OpenPixelCache/3711.
convert: unable to persist pixel cache `./textcleaner_1_30964.mpc' @ error/mpc.c/ReadMPCImage/944.
convert: image sequence is required `-clone' @ error/convert.c/ConvertImageCommand/970.
I already adapted due to the error the final convert command in your script by replacing $tmpA1 with $infile to check if ImageMagick generally works. With this adaption I do not get any errors...

I also uncommented some echos in the script for a better debugging:

Code: Select all

./textcleaner2 -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 scanDoc_1.0.tiff out.jpg
ww=2456; hh=3484; aspect=1
cropoff=; numcrops=0; cropping=
makegray= -colorspace gray -type grayscale
enhancing= -contrast-stretch 0
blurring=-blur 1x65535 -level 30x100%
unrotating=-background white -deskew 40%
sharpening=-sharpen 0x1
modulation=
trimming=-trim +repage 
padding=-compose over -bordercolor white -border 20
Could anybody give me an advice what’s is going wrong?

Thanks a lot in advance!!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

What is your IM version and platform? Did you follow my instructions on my web site to properly install the script and be sure your IM convert is in your PATH environment variable and change the location of dir to /tmp? How big is your Tiff? Does it have multiple layers? My script does not handle multiple layers.

I have never had this problem? Can you provide your input image? You can post to some place such as dropbox.com and put the URL here. Or send it to me directly (fmw at alink dot net).

It seems to be related to

"unable to persist pixel cache `./textcleaner_1_30964.mpc'""

But I do not know exactly what that means. This seems to be related to the first convert from the infile to .mpc format.

I might know more once I have your image and know your IM version and platform and how IM was installed and if you followed my instructions on my home page.

One good test would be to see if you can run any of my examples on the textcleaner page and whether you get errors or not. That would tell me if it is your environment, installation of IM or just your image.
ulli
Posts: 4
Joined: 2016-06-29T10:33:03-07:00
Authentication code: 1151

Re: Error of Textcleaner @Synology

Post by ulli »

I use "Version: ImageMagick 6.9.1-9 Q8 armle 2016-05-31" on a ARM Linux system.
I checked your "Pointers for use:" and found no mistakes. But I think this is confirmed because the script is running by replacing $tmpA1 by $infile like descripted above.
Changing the $dir to /tmp does ether show no positive results

The picture file is a scanned text document in tiff format of 8MB, but I also have checked a smaller picture of a few KB with the same neg. result.

If I simply execute "convert -quiet "i.jpg" +repage "/tmp/textcleaner_1_30964.mpc"" the tmp file *mpc and *cache were created.

I downloaded "http://www.fmwconcepts.com/imagemagick/ ... bbott2.jpg" and got the same failure.

Update: Is it possible that my IM does not know the mpc format?
...looks like, if I replace
tmpA1="$dir/textcleaner_1_$$.mpc"
with
tmpA1="$dir/textcleaner_1_$$.jpg"
it works?
ulli
Posts: 4
Joined: 2016-06-29T10:33:03-07:00
Authentication code: 1151

Re: Error of Textcleaner @Synology

Post by ulli »

Found the issue:
The cache file get lost after the command (mpc still exists)
typegray=`convert $tmpA1 -format '%r' info: | grep 'Gray'`
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

Your system is having trouble or missing grep. MCP is IM's internal format, so it cannot be unknown. Someone else reported a similar issue, but I cannot reproduce it and don't recall if it is related to grep or was some other problem. But they got a similar loss of the mpc or corresponding cache image. Send me your image so I can test with it. It could also be a Q8 (vs Q16) issue with what information %r is providing. I will have to recompile as Q8 and see what is being presented. Does you tif file have transparency or an alpha channel. That might cause %r to report GrayA. I will have to check and get back.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

When you run these, what do you get for the typegray and is the mpc and cache still around?

Code: Select all

convert logo: logo.tif
convert logo.tif logo.mpc
typegray=`convert logo.mpc -format '%r' info: | grep 'Gray'`
echo "typegray=$typegray"
and

Code: Select all

convert logo: -colorspace gray logo.tif
convert logo.tif logo.mpc
typegray=`convert logo.mpc -format '%r' info: | grep 'Gray'`
echo "typegray=$typegray"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

Are you using the latest version of my script. I have made some changes. The latest is dated 6/26/2016.

Is line 395

#trap "rm -f $tmpA1 $tmpA2; exit 1" ERR

commented out. It should be commented so it does not run.

What do you get returned for

convert -version

show me everything. Is HDRI on or off? Is OpenMP on or off? Do you have multiple cores?

Have you tried one of the grep flags and do you have grep on your system? There may be difference is the grep you have and I have.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

This command works fine on my IM 6.9.4.10 and 6.9.1.9 Q16 Mac OSX. No errors or problems losing the .cache file.

Code: Select all

textcleaner -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 abbott2.jpg tmp.jpg
It also works fine for my IM 6.9.1.9 Q8 compile. So my guess is that your system has a different operation for grep or pipe. I am not sure what to suggest other than the tests in my earlier posts or to try some of the other grep flags.

If you can reproduce the issue from my test commands earlier, then we can report that on the Bugs forum and see what the developers suggest.
ulli
Posts: 4
Joined: 2016-06-29T10:33:03-07:00
Authentication code: 1151

Re: Error of Textcleaner @Synology

Post by ulli »

Code: Select all

convert logo: logo.tif
convert logo.tif logo.mpc
typegray=`convert logo.mpc -format '%r' info: | grep 'Gray'`
echo "typegray=$typegray"
the files were created (tif,mpc,cache)
After the execution of the convert command the cache file is gone.
The return value is empty "typegray="
Is can not the gep command because just executing the command "convert logo.mpc -format '%r' info:" returns "PseudoClass sRGB" and afterwards the cache file is gone.

Code: Select all

convert logo: -colorspace gray logo.tif
convert logo.tif logo.mpc
typegray=`convert logo.mpc -format '%r' info: | grep 'Gray'`
echo "typegray=$typegray"
[/quote]
it returns "typegray=DirectClass Gray" and the cache file is also gone.


It looks like it just removes the cache file for that command.
The following works fine and afterwards the cache file still exists:
convert logo.mpc -format "%[colorspace]" info:

Yes, the following is commented out "#trap "rm -f $tmpA1 $tmpA2; exit 1" ERR"
I use the following version "eveloped by Fred Weinhaus 6/9/2009 .......... revised 6/26/2015"

Of course the following command shows the same issue
textcleaner -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 abbott2.jpg tmp.jpg

--> I am pretty sure (100%) the "-format '%r'" is the issue!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

I do not know what is going on. From what you indicate by these tests, it is not my script. So I would suggest you post the following issue to the Bugs forum
"convert logo.mpc -format '%r' info:"

returns "PseudoClass sRGB"

but afterwards the cache file is gone.
Please specify in that post your IM version (exactly what returns from convert -version) and your platform and type of Unix OS

Also show the commands that created logo.mpc
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error of Textcleaner @Synology

Post by fmw42 »

P.S. One possible workaround since you are on a more recent version of Imagemagick is to replace

Code: Select all

typegray=`convert $tmpA1 -format '%r' info: | grep 'Gray'`
with

Code: Select all

typegray=`convert $tmpA1 -format '%[type]' info: | grep 'Grayscale'`
Let me know if that fixes the issue.


You might also test the following to see if the cache file dissappears:

Code: Select all

convert rose: -colorspace gray -format "%r\n" info:
DirectClass Gray

Code: Select all

convert rose: -colorspace gray -format "%r\n" info: | cut -d\  -f2
Gray

(note there are two spaces after -d\ and before -f2)

or

Code: Select all

convert rose: -colorspace gray -format "%r\n" info: | cut -d" " -f2
Gray

If any of these work, then pipe to grep 'Gray' and see if that then works.
Post Reply