Closed ehgusehgus closed 4 years ago
You can use write
method as follows
import jpegio as jio
jpeg = jio.read("image.jpg")
# Modifying jpeg.coef_arrays...
# Modifying jpeg.quant_tables...
jio.write(jpeg, "image_modified.jpg")
jpegio.write() function seems to cause error.
Traceback (most recent call last):
File "
And also something like
jpeg = jio.read("image.jpg") jpeg.write("image_modified.jpg")
does not saving the modified coefficients. It saves with original one.
Refer to the code snippet again, and correct your code as follows, please.
jio.write(jpeg, "image_modified.jpg")
Yes. I've tried like this.
import jpegio
c = jpegio.read('input.jpg')
jpegio.write(c,'image_modified.jpg')
But it produces error like below.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ehgus\Anaconda3\lib\site-packages\jpegio-0.2.1-py3.6-win-amd64.egg\jpegio\io.py", line 20, in write
obj.write(fpath)
File "jpegio\decompressedjpeg.pyx", line 195, in jpegio.decompressedjpeg.DecompressedJpeg.write
File "jpegio\decompressedjpeg.pyx", line 196, in jpegio.decompressedjpeg.DecompressedJpeg.write
File "jpegio\decompressedjpeg.pyx", line 200, in jpegio.decompressedjpeg.DecompressedJpeg._write_markers
TypeError: object of type 'NoneType' has no len()
I think this error is caused by creating empty new object in the writing function and try to save that object.
And if I try the writing like
jpeg = jpegio.read("image.jpg")
jpeg.write("image_modified.jpg")
It does not save the modified coefficient but save the original one
Thanks for giving me the hint.
I've fixed jpegio.write
following your comment.
Test the revised code, please.
Is there a function that save jpeg file with the DCT coefficients and quantization matrix directly?(not with the pixel values)
Thank you for reading