Error Writing to 'PNG'.

40 views
Skip to first unread message

Ak

unread,
May 11, 2024, 1:07:12 AMMay 11
to fo...@jsoftware.com
I hope you are all well,

I am having an issue saving to PNG.

For some inputs, the function operates correctly for others I get this error:


| domain error in writeimg_pplatimg_, executing monad <.
| y is character
|   (qual)=:    <. quality


I am not sure if I have missed something in the documentation.

I appreciate your help.


Ak

bill lam

unread,
May 11, 2024, 2:27:53 AMMay 11
to fo...@jsoftware.com
Please provide a simple script to reproduce the issue and the platform, version, environment, configuration that this issue happens.

To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Ak

unread,
May 19, 2024, 10:00:44 PMMay 19
to fo...@jsoftware.com
Hi Bill,
I hope you had a nice weekend.
Thanks for the response. Your message was in my spam.


j9.5.2/j64avx2/windows
commercial/2024-02-02T18:42:49/clang-16-0-6/SLEEF=1
Library 9.5.6
Qt IDE: 2.5.6/6.5.3(6.5.3)
OS Ver: windows 10 version 22H2 10.0.19045
Platform: Win 64
Installer: j9.5 install
InstallPath: C:/program files/j9.5




data_large  =. (4#256)#. _4]\(?400000000)?@#(4?@#250)    NB. make pixel set to fit on canvas. 
data_small =. (4#256)#. _4]\(?2250000)?@#(4?@#250)         NB. make pixel set to fit on canvas. 

Lines executed:
     ('C:\users\default\j9.5-user\temp\image_00.png') writeimg_pplatimg_~ 20000 20000 $!.(00) data_large
     ('C:\users\default\j.95-user\temp\image_01.png') writeimg_pplatimg_~ 15000 15000 $!.(00) data_small


Both of these forms fail and work variously.



Ak






Marcin Żołek

unread,
May 20, 2024, 4:54:18 AMMay 20
to fo...@jsoftware.com
Please run the following program in JQt in Edit window and send the error you get. On macOS, it seems to work properly.

load 'graphics/pplatimg'
temp_path=: jpath '~temp/'

data_large=: (4#256)#. _4]\(?400000000)?@#(4?@#250)
data_small=: (4#256)#. _4]\(?2250000)?@#(4?@#250)

(temp_path , 'image_00.png') writeimg_pplatimg_~ 20000 20000 $!.(00) data_large
(temp_path , 'image_01.png') writeimg_pplatimg_~ 1500 1500 $!.(00) data_small NB. Did you mean 1500 instead of 15000?

NB. Bonus
load 'media/imagekit'
(1500 1500 3 ?@$ 256) write_image '~temp/image_02.png'


Marcin

bill lam

unread,
May 20, 2024, 9:54:00 AMMay 20
to fo...@jsoftware.com
@AK, I can't reproduce the error either.
I don't understand how quality can become character value.
Run the script from Marcin and bring up the debugger.
Examine the values of y and quality

Raul Miller

unread,
May 20, 2024, 11:16:33 AMMay 20
to fo...@jsoftware.com
I was able to produce an error... though not on my first attempt, and
the error I produced was my own fault - but the consequences of that
error pointed at what I believe are some flaws in the new adhoc
debugging mechanism in j9.6.

On my first attempt, I had to shut down J, because this little laptop
I'm on doesn't like the J image growing to 20 gigabytes.

After reducing the dataset sizes by a factor of 100, and adding the
requisite includes, I got an error from a goof I had introduced.

My variant script;

load 'graphics/pplatimg'
data_large =. (4#256)#. _4]\(?4000000)?@#(4?@#250) NB. make pixel
set to fit on canvas.
data_small =. (4#256)#. _4]\(?22500)?@#(4?@#250) NB. make
pixel set to fit on canvas.
('~temp\image_00.png') writeimg_pplatimg_~ 2000 2000 $!.(00) data_large
('~temp\image_01.png') writeimg_pplatimg_~ 1500 1500 $!.(00) data_small

This failed during the write-to-file because ~temp isn't expanded by
writeimg_pplatimg_

But a couple things were strange during the resulting suspension.
Here's an extract from my session:


|Win32Error: assert
| GdipSaveImageToFile BMP;(u:y,{.a.);ENC;parm
|[-5] c:\users\15712\j9.6-user\temp\8.ijs
Press ENTER to inspect

Use y___1 to look inside top stack frame; see
code.jsoftware.com/wiki/Debug/Stack#irefs
$y___1
$ y___1
y___1
~temp\image_01.png
nc<'y___1'
0


Problem 1: a (verb noun) construct was treated by J as a (verb verb)
construct. I don't think this could have caused a problem for you,
because it's probably a consequence of how the ___1 pseudolocale is
handled.

Problem 2: in the debugging popup, GdipSaveImageToFile was listed as
an undefined local variable. (Because the debugger did not know what
locale it was supposed to be using.)

That said, after correcting my script:

load 'graphics/pplatimg'
data_large =. (4#256)#. _4]\(?4000000)?@#(4?@#250) NB. make pixel
set to fit on canvas.
data_small =. (4#256)#. _4]\(?22500)?@#(4?@#250) NB. make
pixel set to fit on canvas.
(jpath '~temp\image_00.png') writeimg_pplatimg_~ 2000 2000 $!.(00) data_large
(jpath '~temp\image_01.png') writeimg_pplatimg_~ 1500 1500 $!.(00) data_small

I was unable to produce any errors.

FYI,

--
Raul

Ak

unread,
May 20, 2024, 8:20:36 PMMay 20
to fo...@jsoftware.com
Hi Marcin,

I am not sure how this might affect this case but here is more information. 

The way I have been running the write operation is by using:
     require 'viewmat'

I had been using writepng_jpng_ before but I had some other issue. When I looked at the writepng_jpng_ definition I saw that writeimg_pplatimg_ was being used for the case that applied to my use. I then substituted writeimg_pplatimg_ in-place of writepng_jpng_. That issue disappeared, and writeimg_pplatimg_ is how I currently run writes (this is where I get that occasional error).

 
You asked me to try a couple of things.

When I use:
     load 'graphics/pplatimg'

I observe faster writes against my logs.
     For a canvas of 24000 x 24000:
      - historic write times between ~45 to ~95 seconds (many hundreds of samples), down to between ~5 and ~25 seconds on 50 samples). 
      - I have not observed the domain error yet.

When I try to write with a canvas above
The largest canvas that will write consistently is at 30000 x 30000. Greater than this consistently fails with the following:

|Win32Error: assert
|       GdipSaveImageToFile BMP;(u:y,{.a.);ENC;parm


The other test you suggested:
     load 'media/imagekit'

I observe that my whole j session crashes out with the following instruction:
     (1500 1500 3 ?@$ 256) write_image '~temp/image_02.png'



Ak

unread,
May 20, 2024, 9:05:46 PMMay 20
to fo...@jsoftware.com
Hi Raul,

So the only time I get the error:

| Win32Error: assert
|       GdipSaveImageToFile BMP;(u:y,{.a.);ENC;parm

is where the canvas size is greater than 30k by 30k. So is the limiting factor the j-image size induced by the canvas specification? 

Also, I used
      $!.(00)
to avoid a fill conversion from boolean to integer with ($!.(0)) or from float to interger in the absence of a fill specifier. Might this cause any issue?

Ak

unread,
May 20, 2024, 9:12:33 PMMay 20
to fo...@jsoftware.com
Thx Bill, I appreciate you checking. I wasn't sure what role 'quality' plays in the writeimg_pplatimg_ definition. 
I was scratching my head to figure out what I might have done to trigger a change to quality.

bill lam

unread,
May 20, 2024, 10:40:55 PMMay 20
to fo...@jsoftware.com
You use debugger to check.

Henry Rich

unread,
May 21, 2024, 10:42:15 AMMay 21
to fo...@jsoftware.com
I have fixed the error in

   $ y___1

for the next beta release.  References through the debug stack were
checking a Bloom filter that is not valid for those locales.

Henry Rich

Raul Miller

unread,
May 21, 2024, 12:12:48 PMMay 21
to fo...@jsoftware.com
It's unfortunate that the 13!:13 result does not (as best I can tell)
indicate the current locale of a stack frame.

Perhaps column index 7 of the 13!:13 result should be changed to
indicate this locale as the pseudo local '__locale'?

Thanks,

--
Raul
Reply all
Reply to author
Forward
0 new messages