Skip to content

Fix .raw files being detected as text or other formats - #301

Open
masterAllen wants to merge 1 commit into
imagej:masterfrom
masterAllen:fix-raw-detected-as-other-format
Open

Fix .raw files being detected as text or other formats#301
masterAllen wants to merge 1 commit into
imagej:masterfrom
masterAllen:fix-raw-detected-as-other-format

Conversation

@masterAllen

Copy link
Copy Markdown

Reason

Opener.getFileType() identified files by magic numbers and an ASCII heuristic before looking at the .raw extension:

// ImspectorPro MSR
if (name.endsWith(".msr")||name.endsWith(".MSR"))
	return UNKNOWN; // Open with Bio-formats plugin

// Combined TIFF and DICOM created by GE Senographe scanners
if (buf[128]==68 && buf[129]==73 && buf[130]==67 && buf[131]==77
&& ((b0==73 && b1==73)||(b0==77 && b1==77)))
	return TIFF_AND_DICOM;

// ...

// RAW 
if (name.toLowerCase(Locale.US).endsWith(".raw") && !Prefs.skipRawDialog)
	return RAW;

Raw dumps have no header. The first bytes are just pixel data, so they can accidentally look like another format. For example, in low-light photography the pixel values are often small enough to fall in the printable ASCII range, so the original code could easily treat a .raw file as text.

Fix

In ij/io/Opener.java, classify .raw first (case-insensitive), before magic-number and ASCII checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant