`resize image` C++ Examples
21 C++ code examples are found related to "resize image".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: Resize.cpp From PRLib with MIT License | 7 votes |
void prl::resize(const cv::Mat& src, cv::Mat& dst, int scaleX, int scaleY, int nProcessedImageSize) { cv::Mat imageToProc; //! Store source image size cv::Size sourceImageSize(src.size()); cv::Size newImageSize; if (scaleX > 0 && scaleY > 0) { newImageSize = cv::Size( static_cast<int>(src.cols * scaleX), static_cast<int>(src.rows * scaleY) ); cv::resize(src, imageToProc, newImageSize, 0, 0, cv::INTER_AREA); } else {
Example 2
Source File: ImageResize.cpp From BlueshiftEngine with Apache License 2.0 | 6 votes |
void ResizeImageNearest(const T *src, int srcWidth, int srcHeight, T *dst, int dstWidth, int dstHeight, int numComponents) { int srcPitch = srcWidth * numComponents; float ratioX = (float)srcWidth / dstWidth; float ratioY = (float)srcHeight / dstHeight; for (int y = 0; y < dstHeight; y++) { int iY = y * ratioY; int offsetY = iY * srcPitch; for (int x = 0; x < dstWidth; x++) { int iX = x * ratioX; int offsetX = iX * numComponents; const T *srcPtrY = &src[offsetY]; for (int i = 0; i < numComponents; i++) { *dst++ = srcPtrY[offsetX + i]; } } } }
Example 3
Source File: MEImage.cpp From MOTDemo with GNU General Public License v3.0 | 6 votes |
void MEImage::Resize(int new_width, int new_height) { if (new_height < 1) { printf("Invalid new height: %d < 1\n", new_height); return; } if (new_width < 1) { printf("Invalid new width: %d < 1\n", new_width); return; } IplImage* TempImg = cvCreateImage(cvSize(new_width, new_height), 8, ME_CAST_TO_IPLIMAGE(cvImg)->nChannels); cvResize(ME_CAST_TO_IPLIMAGE(cvImg), TempImg, CV_INTER_NN); ME_RELEASE_IPLIMAGE(cvImg); cvImg = TempImg; }
Example 4
Source File: detector_gpu.cpp From ros_opencl_caffe with Apache License 2.0 | 6 votes |
cv::Mat DetectorGpu::resizeImage(const cv::Mat& image) { cv::Mat image_resized; if (image.size() == input_size_) { return image; } if (image.cols != image.rows) { if ((input_size_.width * 1.0 / image.cols) < (input_size_.height * 1.0 / image.rows)) { input_size_resized_.width = input_size_.width; input_size_resized_.height = (image.rows * input_size_.width) / image.cols; } else { input_size_resized_.height = input_size_.height; input_size_resized_.width = (image.cols * input_size_.height) / image.rows; } }
Example 5
Source File: neutral_ops.cpp From nncase with Apache License 2.0 | 6 votes |
kernel_call_result resize_image(resize_image_options &options, interpreter_t &interpreter, interpreter_step_t step) { auto input = interpreter.memory_at<uint8_t>(options.input); auto output = interpreter.memory_at<uint8_t>(options.output); if (options.mode == image_resize_bilinear) { #define RESIZE_BL_KERNEL(T) \ kernels::neutral::resize_bilinear(reinterpret_cast<const T *>(input.data()), reinterpret_cast<T *>(output.data()), options.in_shape, options.out_h, options.out_w, options.align_corners); FP_OR_Q_IMPL(options.input.datatype, RESIZE_BL_KERNEL); return kcr_done; #undef RESIZE_BL_KERNEL } else {
Example 6
Source File: resize_image.cpp From nncase with Apache License 2.0 | 6 votes |
void tflite_importer::convert_resize_image(const tflite::Operator &op, image_resize_mode_t mode) { auto &input = get_tensor(op.inputs(), 0); auto new_size_tensor = load_tensor<int32_t, 1>(get_tensor(op.inputs(), 1)); std::array<int32_t, 2> new_size { new_size_tensor[0], new_size_tensor[1] }; auto align_corners = op.builtin_options_type() == tflite::BuiltinOptions_ResizeBilinearOptions ? op.builtin_options_as_ResizeBilinearOptions()->align_corners() : op.builtin_options_as_ResizeNearestNeighborOptions()->align_corners(); auto pre_trans = nhwc_to_nchw(dt_float32, get_shape(input.shape())); auto node = graph_.emplace<resize_image>(to_data_type(input.type()), mode, pre_trans->output().shape(), new_size, align_corners); auto sur_trans = nchw_to_nhwc(dt_float32, node->output().shape()); node->input().connect(pre_trans->output()); sur_trans->input().connect(node->output()); input_tensors_.emplace(&pre_trans->input(), op.inputs()->Get(0)); output_tensors_.emplace(op.outputs()->Get(0), &sur_trans->output()); }
Example 7
Source File: MEImage.cpp From MOTDemo with GNU General Public License v3.0 | 5 votes |
void MEImage::ResizeScaleX(int new_width) { if (new_width < 1) { printf("Invalid new width: %d < 1\n", new_width); return; } Resize(new_width, (int)((float)new_width*GetRatio())); }
Example 8
Source File: MEImage.cpp From MOTDemo with GNU General Public License v3.0 | 5 votes |
void MEImage::ResizeScaleY(int new_height) { if (new_height < 1) { printf("Invalid new height: %d < 1\n", new_height); return; } Resize((int)((float)new_height * 1 / GetRatio()), new_height); }
Example 9
Source File: resize_image_lmdb.cpp From O-CNN with MIT License | 5 votes |
void resize_image_database(const string& db_name_input, const string& db_name_output, const int width, const int height) { scoped_ptr<db::DB> db_input(db::GetDB(FLAGS_backend)); db_input->Open(db_name_input, db::READ); scoped_ptr<db::Cursor> cursor_input(db_input->NewCursor()); LOG(INFO) << "Writing data to DB"; scoped_ptr<db::DB> db_output(db::GetDB(FLAGS_backend)); db_output->Open(db_name_output, db::NEW); scoped_ptr<db::Transaction> txn_output(db_output->NewTransaction()); LOG(INFO) << "Starting ..."; int count = 0; string octree_output, out_str; Datum datum_input, datum_output; while (cursor_input->valid()) { string key_str = cursor_input->key(); datum_input.ParseFromString(cursor_input->value()); cv::Mat img = DatumToCVMat(datum_input); cv::Mat img_resize; cv::resize(img, img_resize, cv::Size(width, height)); CVMatToDatum(img_resize, &datum_output); datum_output.set_label(datum_input.label()); CHECK(datum_output.SerializeToString(&out_str)); txn_output->Put(key_str, out_str); cursor_input->Next(); if (++count % 1000 == 0) { txn_output->Commit(); txn_output.reset(db_output->NewTransaction()); LOG(INFO) << "Processed " << count << " files."; } } if (count % 10000 != 0) { txn_output->Commit(); LOG(INFO) << "Processed " << count << " files."; } }
Example 10
Source File: Region.cpp From PerfectShow with Apache License 2.0 | 5 votes |
cv::Mat Region::resize(const cv::Mat& image, const Point2f& pivot, float left_scale, float top_scale, float right_scale, float bottom_scale, int interpolation/* = INTER_LINEAR */) { int pivot_x = cvRound(pivot.x), pivot_y = cvRound(pivot.y); // printf("pivot: %d %d, image(%dx%d)", pivot_x, pivot_y, image.cols, image.rows); assert(0 <= pivot_x && pivot_x < image.cols); assert(0 <= pivot_y && pivot_y < image.rows); cv::Mat top, bottom; // seperate the whole image vertically image(Rect2i(0, 0, image.cols, pivot_y)).copyTo(top); image(Rect2i(0, pivot_y, image.cols, image.rows - pivot_y)).copyTo(bottom); const cv::Size EMPTY(0, 0); cv::resize(top, top, EMPTY, 1.0f, top_scale, interpolation); cv::resize(bottom, bottom, EMPTY, 1.0f, bottom_scale, interpolation); cv::Mat result; cv::vconcat(top, bottom, result); cv::Mat left, right; // seperate the whole image horizontally result(Rect2i(0, 0, pivot_x, result.rows)).copyTo(left); result(Rect2i(pivot_x, 0, result.cols - pivot_x, result.rows)).copyTo(right); cv::resize(left, left, EMPTY, left_scale, 1.0f, interpolation); cv::resize(right, right, EMPTY, right_scale, 1.0f, interpolation); cv::hconcat(left, right, result); return result; }
Example 11
Source File: crop_and_resize_gpu.cpp From mlcpp with BSD 2-Clause "Simplified" License | 5 votes |
void crop_and_resize_gpu_backward( at::Tensor grads, at::Tensor boxes, // [y1, x1, y2, x2] at::Tensor box_index, // range in [0, batch_size) at::Tensor grads_image // resize to [bsize, c, hc, wc] ) { // shape const int batch_size = grads_image.size(0); const int depth = grads_image.size(1); const int image_height = grads_image.size(2); const int image_width = grads_image.size(3); const int num_boxes = grads.size(0); const int crop_height = grads.size(2); const int crop_width = grads.size(3); // init output space grads_image.zero_(); CropAndResizeBackpropImageLaucher( grads.data<float>(), boxes.data<float>(), box_index.data<int>(), num_boxes, batch_size, image_height, image_width, crop_height, crop_width, depth, grads_image.data<float>()); }
Example 12
Source File: image_manipulation.cpp From jpp with MIT License | 5 votes |
uchar* resize_image( uchar* &image, int h, int w, int nh, int nw, bool in_place ) { uchar* out = kutility::zeros<uchar>( nh*nw ); double ratioy = h / (double)nh; double ratiox = w / (double)nw; int y, x, ynw; double ny, nx; #pragma omp parallel for private( y, x, ny, nx, ynw ) for( y=0; y<nh; y++ ) { ny = y * ratioy; ynw = y * nw; for( x=0; x<nw; x++ ) { nx = x * ratiox; out[ ynw + x ] = (uchar)bilinear_interpolation( image, w, nx, ny ); } } if( in_place ) { deallocate( image ); image = out; } return out; }
Example 13
Source File: qimdebug.cpp From ClothDesigner with MIT License | 5 votes |
void resizeImage(int w, int h) { if (m_img) { if (!(m_img->width() == w && m_img->height() == h)) { delete m_img; m_img = new QImage(w, h, QImage::Format::Format_ARGB32); } } else
Example 14
Source File: ImageResize.cxx From HopeFOAM with GNU General Public License v3.0 | 4 votes |
int ImageResize(int argc, char *argv[]) { vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New(); vtkSmartPointer<vtkInteractorStyle> style = vtkSmartPointer<vtkInteractorStyle>::New(); vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New(); iren->SetRenderWindow(renWin); iren->SetInteractorStyle(style); vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New(); char* fname = vtkTestUtilities::ExpandDataFileName( argc, argv, "Data/fullhead15.png"); reader->SetFileName(fname); delete[] fname; double range[2] = { 0, 4095 }; for (int i = 0; i < 4; i++) { vtkSmartPointer<vtkImageResize> resize = vtkSmartPointer<vtkImageResize>::New(); resize->SetInputConnection(reader->GetOutputPort()); resize->SetOutputDimensions(64, 64, 1); vtkSmartPointer<vtkImageSliceMapper> imageMapper = vtkSmartPointer<vtkImageSliceMapper>::New(); imageMapper->SetInputConnection(resize->GetOutputPort()); imageMapper->BorderOn(); if ((i & 1) == 0) { resize->BorderOff(); } else { resize->BorderOn(); } if ((i & 2) == 0) { resize->InterpolateOff(); } else {
Example 15
Source File: ImageResize.cpp From BlueshiftEngine with Apache License 2.0 | 4 votes |
static void ResizeImageBilinear(const T *src, int srcWidth, int srcHeight, T *dst, int dstWidth, int dstHeight, int numComponents) { int srcPitch = srcWidth * numComponents; float ratioX = (float)srcWidth / dstWidth; float ratioY = (float)srcHeight / dstHeight; for (int y = 0; y < dstHeight; y++) { float fY0 = y * ratioY; float fracY = Math::Fract(fY0); int iY0 = fY0 - fracY; int iY1 = Min(iY0 + 1, srcHeight - 1); int offsetY0 = iY0 * srcPitch; int offsetY1 = iY1 * srcPitch; for (int x = 0; x < dstWidth; x++) { float fX0 = x * ratioX; float fracX = Math::Fract(fX0); int iX0 = fX0 - fracX; int iX1 = Min(iX0 + 1, srcWidth - 1); int offsetX0 = iX0 * numComponents; int offsetX1 = iX1 * numComponents; const T *srcPtrY[2]; srcPtrY[0] = &src[offsetY0]; srcPtrY[1] = &src[offsetY1]; for (int i = 0; i < numComponents; i++) { int index0 = offsetX0 + i; int index1 = offsetX1 + i; // NOTE: Should we need to lerp in linear color space ? float p0 = Lerp<float>(srcPtrY[0][index0], srcPtrY[0][index1], fracX); float p1 = Lerp<float>(srcPtrY[1][index0], srcPtrY[1][index1], fracX); float po = Lerp<float>(p0, p1, fracY); *dst++ = po; } } } }
Example 16
Source File: ImageResize.cpp From BlueshiftEngine with Apache License 2.0 | 4 votes |
static void ResizeImageBicubic(const T *src, int srcWidth, int srcHeight, T *dst, int dstWidth, int dstHeight, int numComponents) { int srcPitch = srcWidth * numComponents; float ratioX = (float)srcWidth / dstWidth; float ratioY = (float)srcHeight / dstHeight; for (int y = 0; y < dstHeight; y++) { float fY1 = y * ratioY; float fracY = Math::Fract(fY1); int iY1 = fY1 - fracY; int iY0 = Max(iY1 - 1, 0); int iY2 = Min(iY1 + 1, srcHeight - 1); int iY3 = Min(iY1 + 2, srcHeight - 1); int offsetY0 = iY0 * srcPitch; int offsetY1 = iY1 * srcPitch; int offsetY2 = iY2 * srcPitch; int offsetY3 = iY3 * srcPitch; for (int x = 0; x < dstWidth; x++) { float fX1 = x * ratioX; float fracX = Math::Fract(fX1); int iX1 = fX1 - fracX; int iX0 = Max(iX1 - 1, 0); int iX2 = Min(iX1 + 1, srcWidth - 1); int iX3 = Min(iX1 + 2, srcWidth - 1); int offsetX0 = iX0 * numComponents; int offsetX1 = iX1 * numComponents; int offsetX2 = iX2 * numComponents; int offsetX3 = iX3 * numComponents; const T *srcPtrY[4]; srcPtrY[0] = &src[offsetY0]; srcPtrY[1] = &src[offsetY1]; srcPtrY[2] = &src[offsetY2]; srcPtrY[3] = &src[offsetY3]; for (int i = 0; i < numComponents; i++) { int index0 = offsetX0 + i; int index1 = offsetX1 + i; int index2 = offsetX2 + i; int index3 = offsetX3 + i; // NOTE: Should we need to lerp in linear color space ? float p0 = Cerp<float>(srcPtrY[0][index0], srcPtrY[0][index1], srcPtrY[0][index2], srcPtrY[0][index3], fracX); float p1 = Cerp<float>(srcPtrY[1][index0], srcPtrY[1][index1], srcPtrY[1][index2], srcPtrY[1][index3], fracX); float p2 = Cerp<float>(srcPtrY[2][index0], srcPtrY[2][index1], srcPtrY[2][index2], srcPtrY[2][index3], fracX); float p3 = Cerp<float>(srcPtrY[3][index0], srcPtrY[3][index1], srcPtrY[3][index2], srcPtrY[3][index3], fracX); float po = Cerp<float>(p0, p1, p2, p3, fracY); *dst++ = ClampFloat(std::numeric_limits<T>::min(), std::numeric_limits<T>::max(), po); } } } }
Example 17
Source File: image_resizer.cpp From streaming_connected_component_discovery with GNU General Public License v3.0 | 4 votes |
image_resizer::ImageResizer::ResizeResult image_resizer::ImageResizer::resize_image( const unsigned char * const input_image_data, const int input_image_width, const int input_image_height, const core::colorspace::Colorspace input_image_colorspace, unsigned char * const output_preallocated_image_data, const int output_preallocated_image_data_size) { if (m_resize_mode == Resized) { // Test to see if the image needs to be resized. if (input_image_width > m_resized_image_dimension || input_image_height > m_resized_image_dimension) { // The image needs to be resized, so create an OpenCV wrapper around // the input image. const cv::Mat input_image( input_image_height, // Number of rows. input_image_width, // Number of columns. core::colorspace::convert_to_opencv(input_image_colorspace), const_cast<unsigned char *>(input_image_data)); ResizeResult result; // Compute the new (resized) width and height of the image. if (input_image_width > input_image_height) { result.scale = float(m_resized_image_dimension) / float(input_image_width); result.width = m_resized_image_dimension; result.height = static_cast<int>(result.scale * float(input_image_height) + 0.5f); } else // if (input_image_width <= input_image_height) { result.scale = float(m_resized_image_dimension) / float(input_image_height); result.height = m_resized_image_dimension; result.width = static_cast<int>(result.scale * float(input_image_width) + 0.5f); } const int required_data_size = result.width * result.height * core::colorspace::num_bytes_per_pixel(input_image_colorspace); if (required_data_size > output_preallocated_image_data_size) { std::cerr << "ERROR: ImageResizer::resize_image() - not enough preallocated image data" << std::endl; result.clear(); return result; } // Create an OpenCV wrapper for the final image. cv::Mat resized_image( result.height, result.width, core::colorspace::convert_to_opencv(input_image_colorspace), output_preallocated_image_data); // Resize the image. cv::resize( input_image, resized_image, cv::Size(result.width, result.height), 0, 0, CV_INTER_AREA); return result; } else // if (input_image_width <= m_resized_image_dimension && // input_image_height <= m_resized_image_dimension) {
Example 18
Source File: interp_float.cpp From Tengine with Apache License 2.0 | 4 votes |
static void resize_bilinear_image(float* src, float* dst, float* alpha, int* xofs, float* beta, int* yofs, int out_h, int out_w, int in_h, int in_w) { int w = out_w; //dst.w; int h = out_h; //dst.h; // loop body float* rowsbuf0 = ( float* )std::malloc(w * sizeof(float)); float* rowsbuf1 = ( float* )std::malloc(w * sizeof(float)); float* rows0 = rowsbuf0; float* rows1 = rowsbuf1; int prev_sy1 = -2; for (int dy = 0; dy < h; dy++ ) { int sy = yofs[dy]; if (sy == prev_sy1) { // reuse all rows } else if (sy == prev_sy1 + 1) { // hresize one row float* rows0_old = rows0; rows0 = rows1; rows1 = rows0_old; const float* S1 = src + (sy+1)*in_w; //src.row(sy+1); const float* alphap = alpha; float* rows1p = rows1; // neon for (int dx = 0; dx+1 < w; dx += 2 ) { int sx = xofs[dx]; int sxn = xofs[dx+1]; const float* S1p = S1 + sx; const float* S1np = S1 + sxn; float32x4_t _a = vld1q_f32(alphap); float32x2_t _S1 = vld1_f32(S1p); float32x2_t _S1n = vld1_f32(S1np); float32x4_t _S1S1n = vcombine_f32(_S1, _S1n); float32x4_t _ms1 = vmulq_f32(_S1S1n, _a); float32x2_t _rows1 = vpadd_f32(vget_low_f32(_ms1), vget_high_f32(_ms1)); vst1_f32(rows1p + dx, _rows1); alphap += 4; } // for (int dx = 0; dx < w; dx++) // { // int sx = xofs[dx]; // const float* S1p = S1 + sx; // float a0 = alphap[0]; // float a1 = alphap[1]; // rows1p[dx] = S1p[0]*a0 + S1p[1]*a1; // alphap += 2; // } } else {
Example 19
Source File: DirectXTexResize.cpp From Xbox-ATG-Samples with MIT License | 4 votes |
HRESULT PerformResizeUsingWIC( const Image& srcImage, DWORD filter, const WICPixelFormatGUID& pfGUID, const Image& destImage) noexcept { if (!srcImage.pixels || !destImage.pixels) return E_POINTER; assert(srcImage.format == destImage.format); bool iswic2 = false; auto pWIC = GetWICFactory(iswic2); if (!pWIC) return E_NOINTERFACE; ComPtr<IWICComponentInfo> componentInfo; HRESULT hr = pWIC->CreateComponentInfo(pfGUID, componentInfo.GetAddressOf()); if (FAILED(hr)) return hr; ComPtr<IWICPixelFormatInfo2> pixelFormatInfo; hr = componentInfo.As(&pixelFormatInfo); if (FAILED(hr)) return hr; BOOL supportsTransparency = FALSE; hr = pixelFormatInfo->SupportsTransparency(&supportsTransparency); if (FAILED(hr)) return hr; if (srcImage.rowPitch > UINT32_MAX || srcImage.slicePitch > UINT32_MAX || destImage.rowPitch > UINT32_MAX || destImage.slicePitch > UINT32_MAX) return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); ComPtr<IWICBitmap> source; hr = pWIC->CreateBitmapFromMemory(static_cast<UINT>(srcImage.width), static_cast<UINT>(srcImage.height), pfGUID, static_cast<UINT>(srcImage.rowPitch), static_cast<UINT>(srcImage.slicePitch), srcImage.pixels, source.GetAddressOf()); if (FAILED(hr)) return hr; if ((filter & TEX_FILTER_SEPARATE_ALPHA) && supportsTransparency) { hr = _ResizeSeparateColorAndAlpha(pWIC, iswic2, source.Get(), destImage.width, destImage.height, filter, &destImage); if (FAILED(hr)) return hr; } else {
Example 20
Source File: resize_nearest_neighbor.cc From mace with Apache License 2.0 | 4 votes |
inline void ResizeImageNCHW(const OpContext *context, const T *images, const index_t batch_size, const index_t in_height, const index_t in_width, const index_t out_height, const index_t out_width, const index_t channels, const float height_scale, const float width_scale, bool align_corners, T *output) { utils::ThreadPool &thread_pool = context->device()->cpu_runtime()->thread_pool(); thread_pool.Compute2D([=](index_t start0, index_t end0, index_t step0, index_t start1, index_t end1, index_t step1) { for (index_t b = start0; b < end0; b += step0) { for (index_t c = start1; c < end1; c += step1) { const T *channel_input_ptr = images + (b * channels + c) * in_height * in_width; T *channel_output_ptr = output + (b * channels + c) * out_height * out_width; for (index_t y = 0; y < out_height; ++y) { const index_t in_y = std::min( (align_corners) ? static_cast<index_t>(roundf(y * height_scale)) : static_cast<index_t>(floorf(y * height_scale)), in_height - 1); for (int x = 0; x < out_width; ++x) { const index_t in_x = std::min( (align_corners) ? static_cast<index_t>(roundf(x * width_scale)) : static_cast<index_t>(floorf(x * width_scale)), in_width - 1); channel_output_ptr[y * out_width + x] = channel_input_ptr[in_y * in_width + in_x]; } } } } }, 0, batch_size, 1, 0, channels, 1); }
Example 21
Source File: resize.c From awtk with GNU Lesser General Public License v2.1 | 4 votes |
static int image_resize(const char* ifilename, const char* ofilename, int ow, int oh) { int n = 0; int iw = 0; int ih = 0; int ret = 0; unsigned char* odata = NULL; unsigned char* idata = stbi_load(ifilename, &iw, &ih, &n, 0); if (idata != NULL) { if (ow == 0) { ow = (oh * iw) / ih; } if (oh == 0) { oh = (ow * ih) / iw; } odata = (unsigned char*)malloc(ow * oh * n); if (odata != NULL) { ret = stbir_resize_uint8(idata, iw, ih, iw * n, odata, ow, oh, ow * n, n); if (ret != 0) { if (strstr(ofilename, ".png") != NULL) { ret = stbi_write_png(ofilename, ow, oh, n, odata, ow * n); } else if (strstr(ofilename, ".jpg") != NULL) { ret = stbi_write_jpg(ofilename, ow, oh, n, odata, 90); } else { ret = 0; printf("not supported file format.\n"); } if (ret != 0) { int w = 0; int h = 0; unsigned char* data = stbi_load(ofilename, &w, &h, &n, 0); assert(w == ow && h == oh && data != NULL); if (w == ow && h == oh) { printf("image resize success:%s(%dx%d) => %s(%dx%dx%d)\n", ifilename, iw, ih, ofilename, ow, oh, n); } stbi_image_free(data); } else { printf("write failed\n"); } }