don't read headers unnecessarily

This commit is contained in:
David Rose 2005-06-01 05:59:00 +00:00
parent d21af49d00
commit 741ac58078

View File

@ -290,24 +290,10 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
} else if (force_reduced) { } else if (force_reduced) {
// Even though the reduced image would not be smaller, copy it // Even though the reduced image would not be smaller, copy it
// anyway when force_reduced is true. // anyway when force_reduced is true.
nout << "Reading " << photo_filename << "\n"; photo_filename.set_binary();
if (!reduced_image.read(reader)) { if (!copy_file(photo_filename, reduced_dir)) {
nout << "Unable to read.\n";
return false; return false;
} }
reader = NULL;
reduced_filename.make_dir();
nout << "Writing " << reduced_filename << "\n";
if (!reduced_image.write(reduced_filename)) {
nout << "Unable to write.\n";
delete reader;
return false;
}
photo->_has_reduced = true;
photo->_reduced_x_size = reduced_image.get_x_size();
photo->_reduced_y_size = reduced_image.get_y_size();
} else { } else {
// We're not making a reduced version. But maybe we still // We're not making a reduced version. But maybe we still
@ -332,6 +318,7 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
// If the reduced image already exists and is newer than the // If the reduced image already exists and is newer than the
// source image, use it. // source image, use it.
if (!force_reduced) {
// We still read the image header to determine its size. // We still read the image header to determine its size.
PNMImageHeader photo_image; PNMImageHeader photo_image;
if (!photo_image.read_header(photo_filename)) { if (!photo_image.read_header(photo_filename)) {
@ -375,6 +362,7 @@ make_reduced_image(Photo *photo, PNMImage &reduced_image,
photo->_reduced_y_size = reduced_image.get_y_size(); photo->_reduced_y_size = reduced_image.get_y_size();
} }
} }
}
return true; return true;
} }