-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
- OS: OSX 11.6
- Python: 3.7.4
- Pillow: 9.1.1
eps_file_path = "EPS_Bitmap.eps" # File was attached.
img = Image.open(eps_file_path)
print(img.mode, img.size) # RGB (90, 60) --> correct: L, (500,333)Am I doing it the wrong way? This is how I'm using it for now (getting data from %ImageData).Thank you.
def get_eps_info(eps_file_path):
"""
https://mail.python.org/pipermail/image-sig/2005-September/003575.html
Photoshop 6.0 SDK
EPS Parameters for ImageData (Photoshop 3.0 and later)
columns Width of the image in pixels
rows Height of the image in pixels
depth Number of bits per channel. Must be 1 or 8
mode Image mode. Bitmap/grayscale = 1; Lab = 2; RGB = 3; CMYK = 4
pad channels Number of other channels stored in the file.
Ignored when reading...
block size Number of bytes per row per channel.
Will be either 1 or formula (below):
1 = Data is interleaved
(columns*depth+7)/8 = Data is stored in line interleaved format
or there is only one channel
binary/ascii 1 = Data is in binary format
2 = Data is in hex ascii format
data start Entire PostScriptline immediately preceding the image data.
This entire line should not occur elewhere in the PostScript
header code, but it may occur at part of line
"""
p = re.compile(rb'%ImageData:\s(\d.+)\s"beginimage"')
with open(eps_file_path, "rb") as f:
for line in f.readlines():
info = re.match(p, line)
if info:
columns, rows, depth, mode, pad_channels, block_size, data_format = map(
lambda x: int(x), info.group(1).decode().split(" "))
return columns, rows, mode
print(get_eps_info(eps_file_path)) # (500, 333, 1)Metadata
Metadata
Assignees
Labels
No labels