libvips / pyvips

python binding for libvips using cffi
MIT License
649 stars 50 forks source link

referenced memory is not changed. #503

Closed sunwoo76 closed 1 month ago

sunwoo76 commented 2 months ago
    image = pyvips.Image.new_from_file(svg_path)
    image.write_to_file(os.path.join(png_path)) # first-saving

   ~~ some code for changing the content in svg file from "svg_path" ~~

    image = pyvips.Image.new_from_file(svg_path)
    image.write_to_file(os.path.join(png_path)) # second-saving

In this case, the svg contents are changed in the middle of the code. After changing the content and re-write to the same svg_path and read again with the same svg_path.

However, the first-saving result and second-saving result are the same.

How can I treat this?

Thank you.

jcupitt commented 2 months ago

Hello @sunwoo76,

libvips caches many operations to improve speed. You can force a loader to go back to the source and reload the image with:

image = pyvips.Image.new_from_file(svg_path, revalidate=True)
sunwoo76 commented 1 month ago

Hello @sunwoo76,

libvips caches many operations to improve speed. You can force a loader to go back to the source and reload the image with:

image = pyvips.Image.new_from_file(svg_path, revalidate=True)

Thank you for replying :)

However, the new error has occured:

  File "./get_render_310.py", line 380, in <module>
    image = pyvips.Image.new_from_file(svg_path, revalidate=True)
  File "/home/psc/anaconda3/lib/python3.8/site-packages/pyvips/vimage.py", line 352, in new_from_file
    return pyvips.Operation.call(name, filename,
  File "/home/psc/anaconda3/lib/python3.8/site-packages/pyvips/voperation.py", line 290, in call
    raise Error('{0} does not support optional argument {1}'
pyvips.error.Error: VipsForeignLoadMagickFile does not support optional argument revalidate

I checked the supported argumnet of "VipsForeignLoadMagickFile". The results as below: input: ['all_frames', 'density', 'disc', 'access', 'sequential'] output: ['flags']

It seems that the optional argument is not supported.

ps. My current pyvips version is 2.2.3.

jcupitt commented 1 month ago

revalidate was added in libvips 8.15, perhaps you are using an older version?