Sublime Forum

Plain .ppm is not really supported

#1

PPM means (p)ortable (p)ix(m)ap

Format specification: https://netpbm.sourceforge.net/doc/ppm.html

It’s text format with structure like <label> <width> <height> <max_value> (<red> <green> <blue>)

I am using “Plain PPM” for my experiments. It means <label> is P3 and color component values are encoded as decimals in ASCII.

This snippet conforms to specification. It’s opened without problems by Xviewer:

P3 1 1 255 0 255 255

image

Sublime 4180 correctly believes it is image but fails to display it. I have to “Reopen File as Text” every time.

I believe it’s not hard to parse integers from string in Python. If not, just display it as text.

(Despite this minor issue your project is great! Using it for over 10 years.)

Best regards, Martin

0 Likes

#2

That looks like it’s displaying the image correctly. You can change which files get opened as images by default using the "image_file_patterns" setting.

0 Likes

#3

Image is a screenshot from Xviewer.

0 Likes

#4

Right. Sublime Text uses stb_image, and so only supports binary ppm files for image preview.

0 Likes

#5

No problems.

Actually I don’t expect text editor to display images.

But if it does (or at least tries to) and fails, can it fallback to text format? (And to binary format, if text loading also fails.)

Because from “ordinary user”'s point of view, program tries to do some unasked stuff and fails. Not gracefully. User needs to click “File”, click “Reopen File as Text”. And setting default loading mode for .ppm as Plain Text is not honored.

From my personal point of view, determining file format by extension is okay but needs further file header checks to be sure. In .ppm first non-comment entry can be P6 or P3. P6 is okay and supported, on P3 image loader should gracefully fail and fallback to text loader.

0 Likes

#6

Thank you! Removing "*.ppm" from image_file_patterns list alleviated this issue.

0 Likes