Exemplo n.º 1
0
void ImageGetter::resizeJPGImage(std::string const& imageURL, int sixex, int sizey)
{
	boost::gil::rgb8_image_t img;
	jpeg_read_image(imageURL,img);
	

    boost::gil::rgb8_image_t targetImageSize(sixex,sizey);

    resize_view(const_view(img), view(targetImageSize), boost::gil::bilinear_sampler());
    jpeg_write_view(imageURL,const_view(targetImageSize));
}
Exemplo n.º 2
0
void boost_parse_image(std::string filename, size_t& width, size_t& height, size_t& channels, Format& format, size_t& image_data_size, std::string format_string) {

  typedef boost::mpl::vector<gray8_image_t, gray16_image_t, rgb8_image_t, rgb16_image_t> my_img_types;

  any_image<my_img_types> src_image;

  if (format_string == "JPG"){
    jpeg_read_image(filename, src_image);
    format = Format::JPG;
  } else if (format_string == "PNG"){
    png_read_image(filename, src_image);
    format = Format::PNG;
  } else{
    if (boost::algorithm::ends_with(filename, "jpg") ||
      boost::algorithm::ends_with(filename, "jpeg")) {
      jpeg_read_image(filename, src_image);
      format = Format::JPG;
    } else if (boost::algorithm::ends_with(filename, "png")){
      png_read_image(filename, src_image);
      format = Format::PNG;
    } else {
      log_and_throw(std::string("Unsupported format."));
    }
  }

  // create a view of the image
  auto src_view = const_view(src_image);

  // extract image information
  width = src_view.width();
  height = src_view.height();
  channels = src_view.num_channels();
  image_data_size = width*height*channels;

  // Debug
  // std::cout << "Read image "<< filename << "\n"
  // << "width: " << width << "\n"
  // << "height: " << height << "\n"
  // << "num_channels " << channels << "\n"
  // << std::endl;
}
Exemplo n.º 3
0
inline void jpeg_read_image(const std::string& filename,Image& im) {
    jpeg_read_image(filename.c_str(),im);
}