image.resize returning 0 bytes

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
sacah
Posts: 1
Joined: 2016-02-19T15:38:33-07:00
Authentication code: 1151

image.resize returning 0 bytes

Post by sacah »

Hi,
I've hit a problem I'm unsure how to debug further, I have the below code which reads in an image, resizes it and returns it. This worked fine until my C drive filled up with tmp files and the program died. I cleared the magick tmp files out so the C drive has lots of free room now, but when I run my code again, image.fileSize() returns 0 after the image.resize(). So with the code below, File1 filesize will be 570639, File2 will be 570639, but File3 & File4 will be 0

Code: Select all

Image myResizeImage(string imgPath, int width, int height) {
	Image image;
	try {
		image.read(imgPath);
		cout << "File1: " << imgPath << " : " << image.fileSize() << '\n';
	} catch (WarningCoder &warning) {
		cout << "Coder Warning: " << warning.what() << '\n';
	} catch (Warning &warning) {
		cout << "Warning: " << warning.what() << '\n';
	} catch (ErrorFileOpen &error) {
		cout << "Error: " << error.what() << '\n';
		return image;
	} catch (ErrorCorruptImage &error) {
		cout << "Error: " << error.what() << '\n';
		return image;
	}
	Geometry newSize = Geometry(width, height);
	newSize.aspect(false);
	cout << "File2: " << imgPath << " : " << image.fileSize() << '\n';
	image.resize(newSize);
	cout << "File3: " << imgPath << " : " << image.fileSize() << '\n';
	image.type(GrayscaleType);
	//image.resize(newSize);
	cout << "File4: " << imgPath << " : " << image.fileSize() << '\n';
	return image;
}
I tried starting a new Visual Studio project, I've moved code around, tried variations etc, I'm stuck as to what could be the problem, any tips on what might be wrong?

Thanks
Post Reply