-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
backup/ | ||
build/ | ||
temp/ | ||
testcases/ | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,15 @@ | |
01.002 Changed from self-contained to modular, IncSrc and IncScaleNx modules created | ||
01.003 Ultimate modular evil, moving everything possible to IncSrc.py and IncScaleNx.py | ||
2024.02.24 Cleanup, minimizing import, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -55,13 +56,29 @@ | |
# Reshaping 2x scaled 3D list into 1D list for PyPNG .write_array method | ||
ResultImageAsList = IncSrc.Img3Dto1D(EPXImage, doubleX, doubleY, Z) | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 2*x_pixels_per_unit # Double resolution to keep print size | ||
y_pixels_per_unit = 2*y_pixels_per_unit # Double resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Open export file | ||
|
||
resultPNG = open(Dvo, mode='wb') | ||
# Writing export file | ||
writer = png.Writer(doubleX, doubleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(doubleX, doubleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ | |
01.003 Ultimate modular evil, moving everything possible to IncSrc.py and IncScaleNx.py | ||
01.004 Progress indication added, showing processing stage | ||
2024.02.24 Cleanup, GUI tweaks, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -117,10 +118,27 @@ | |
# Export file opened | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 2*x_pixels_per_unit # Double resolution to keep print size | ||
y_pixels_per_unit = 2*y_pixels_per_unit # Double resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Writing export file | ||
|
||
writer = png.Writer(doubleX, doubleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(doubleX, doubleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,15 @@ | |
01.002 Changed from self-contained to modular, IncSrc and IncScaleNx modules created | ||
01.003 Ultimate modular evil, moving everything possible to IncSrc.py and IncScaleNx.py | ||
2024.02.24 Cleanup, minimizing import, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -56,11 +57,28 @@ | |
# Reshaping 3x scaled 3D list into 1D list for PyPNG .write_array method | ||
ResultImageAsList = IncSrc.Img3Dto1D(EPXImage, tripleX, tripleY, Z) | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 3*x_pixels_per_unit # Triple resolution to keep print size | ||
y_pixels_per_unit = 3*y_pixels_per_unit # Triple resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Open export file | ||
resultPNG = open(Dvo, mode='wb') | ||
# Writing export file | ||
writer = png.Writer(tripleX, tripleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(tripleX, tripleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
# Export file closed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ | |
01.003 Ultimate modular evil, moving everything possible to IncSrc.py and IncScaleNx.py | ||
01.004 Progress indication added, showing processing stage | ||
2024.02.24 Cleanup, GUI tweaks, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -117,10 +118,27 @@ | |
# Export file opened | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 3*x_pixels_per_unit # Triple resolution to keep print size | ||
y_pixels_per_unit = 3*y_pixels_per_unit # Triple resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# -------------------------------------------------------------- | ||
# Writing export file | ||
|
||
writer = png.Writer(tripleX, tripleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(tripleX, tripleY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,15 @@ | |
01.000 Initial working release | ||
01.001 Progress indication added, showing name of file being processed | ||
2024.02.24 Cleanup, GUI tweaks, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -64,7 +65,7 @@ | |
for runningfilename in glob(sourcedir + "/**/*.png", recursive=True): # select all PNG files in all subfolders | ||
|
||
oldfile = runningfilename | ||
newfile = oldfile + '.2x.png' # If you wish originals to be replaced, set newfile = oldfile | ||
newfile = oldfile # Previous version used backup newfile = oldfile + '.2x.png' | ||
|
||
zanyato.config(text = oldfile) # Updating label, showing processed file name | ||
sortir.update() | ||
|
@@ -85,9 +86,26 @@ | |
# Reshaping 2x scaled 3D list into 1D list for PyPNG .write_array method | ||
ResultImageAsList = IncSrc.Img3Dto1D(EPXImage, newX, newY, Z) | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 2*x_pixels_per_unit # Double resolution to keep print size | ||
y_pixels_per_unit = 2*y_pixels_per_unit # Double resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# Writing new image | ||
resultPNG = open(newfile, mode='wb') | ||
writer = png.Writer(newX, newY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(newX, newY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,15 @@ | |
01.000 Initial working release | ||
01.001 Progress indication added, showing name of file being processed | ||
2024.02.24 Cleanup, GUI tweaks, versioning changed to YYYY.MM.DD | ||
2024.03.30 pHYs chunk editing to keep image print size constant | ||
''' | ||
|
||
__author__ = "Ilya Razmanov" | ||
__copyright__ = "(c) 2024 Ilya Razmanov" | ||
__credits__ = "Ilya Razmanov" | ||
__license__ = "unlicense" | ||
__version__ = "2024.02.24" | ||
__version__ = "2024.03.30" | ||
__maintainer__ = "Ilya Razmanov" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
@@ -64,7 +65,7 @@ | |
for runningfilename in glob(sourcedir + "/**/*.png", recursive=True): # select all PNG files in all subfolders | ||
|
||
oldfile = runningfilename | ||
newfile = oldfile + '.3x.png' # If you wish originals to be replaced, set newfile = oldfile | ||
newfile = oldfile # Previous version used backup newfile = oldfile + '.3x.png' | ||
|
||
zanyato.config(text = oldfile) # Updating label, showing processed file name | ||
sortir.update() | ||
|
@@ -85,9 +86,26 @@ | |
# Reshaping 3x scaled 3D list into 1D list for PyPNG .write_array method | ||
ResultImageAsList = IncSrc.Img3Dto1D(EPXImage, newX, newY, Z) | ||
|
||
# -------------------------------------------------------------- | ||
# Fixing resolution to match original print size. | ||
# If no pHYs found in original, 96 ppi is assumed as original value. | ||
if 'physical' in info: | ||
res = info['physical'] # Reading resolution as tuple | ||
x_pixels_per_unit = res[0] | ||
y_pixels_per_unit = res[1] | ||
unit_is_meter = res[2] | ||
else: | ||
x_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
y_pixels_per_unit = 3780 # 3780 px/meter = 96 px/inch, 2834 px/meter = 72 px/inch | ||
unit_is_meter = True | ||
x_pixels_per_unit = 3*x_pixels_per_unit # Triple resolution to keep print size | ||
y_pixels_per_unit = 3*y_pixels_per_unit # Triple resolution to keep print size | ||
# Resolution changed | ||
# -------------------------------------------------------------- | ||
|
||
# Writing new image | ||
resultPNG = open(newfile, mode='wb') | ||
writer = png.Writer(newX, newY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth']) | ||
writer = png.Writer(newX, newY, greyscale = info['greyscale'], alpha = info['alpha'], bitdepth = info['bitdepth'], physical = [x_pixels_per_unit, y_pixels_per_unit, unit_is_meter]) | ||
writer.write_array(resultPNG, ResultImageAsList) | ||
resultPNG.close() | ||
|
||
|