dwgoon / jpegio

A python package for accessing the internal variables of JPEG file format such as DCT coefficients and quantization tables
Apache License 2.0
73 stars 18 forks source link

jpegio.write saves the original coefs rather than the modified coefs #20

Open zhahongyue opened 2 years ago

zhahongyue commented 2 years ago

I have to modify a grayscale jpeg's dct coef and save it to another path. But it seems that jpegio.write() saves the original coefs rather than the modified coefs. Could you please check this out for me? Thanks a lot!

######################################

import jpegio as jio #jpegio version is 0.2.2 import imageio import numpy as np

cover = jio.read(cover_path) cover_coef_input = np.array(cover.coef_arrays[0]) cover.coef_arrays[0] = cover.coef_arrays[0] + pert
cover_coef_modified = np.array(cover.coef_arrays[0]) jio.write(cover, stego_path)

cover = jio.read(cover_path) cover_coef = np.array(cover.coef_arrays[0]) cover_spatial = imageio.imread(cover_path) stego = jio.read(stego_path)
stego_coef = np.array(stego.coef_arrays[0])
stego_spatial = imageio.imread(stego_path)

print('num_cin_cm_diff:',np.sum(cover_coef_modified!=cover_coef_input)) # 1034 print('num_cin_c_diff:',np.sum(cover_coef!=cover_coef_input)) # 0 print('num_c_s_diff:',np.sum(cover_coef!=stego_coef)) # 0 print('num_cm_s_diff:',np.sum(cover_coef_modified!=stego_coef)) # 1034 print('num_c_s_spatial_diff:',np.sum(cover_spatial!=stego_spatial)) # 0

dwgoon commented 2 years ago

Thanks for reporting the issue. Could you please upload or send me an example file (i.e., the grayscale JPEG file)?

zhahongyue commented 2 years ago

cover.zip Thanks for your consideration. Some example grayscale JPEG files are in the above zip file url.

johtai commented 11 months ago

I faced the same issue, when I tried to modify the coefficients in my image. So I guess there is no solution for now?

Kwisss commented 2 months ago

So this whole repo can be considered as not working?

dwgoon commented 2 months ago

Try the below project, which is more comprehensive and supported.

https://github.com/martinbenes1996/jpeglib