I'm trying to convert .hdr and .exr images to resized .png images. The conversion part works as expected but when I try to resize the image before saving the result is just a black image. I'm using the latest OpenImageIO from github.
// read in an HDR or exr image
auto in = ImageInput::open (image_path.hdr);
const ImageSpec& spec = in->spec();
int w = spec.width;
int h = spec.height;
int channels = spec.nchannels;
// convert float to UNIT8
std::vector<unsigned char> pixels (w * h * channels);
in->read_image (TypeDesc::UINT8, pixels.data());
// resize and save to png format
ImageSpec s;
s.format = TypeDesc::UINT8;
s.width = w;
s.height = h;
s.nchannels = channels;
ImageBuf A (s, pixels.data());
// without resizing saving to .png works correctly
A.write(image_path.png);
// this results in an all black image
ROI roi (0, w/2, 0, h/2, 0, 1, 0,channels);
ImageBuf B;
ImageBufAlgo::resize (B, A, "", 0, roi);
B.write(image_path.png);