Guest User

Untitled

a guest
Jan 24th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /* compile with:
  2. * g++ -g -Wall example.cc `pkg-config vips-cpp --cflags --libs`
  3. */
  4.  
  5. #include <vips/vips8>
  6.  
  7. using namespace vips;
  8.  
  9. int
  10. main (int argc, char **argv)
  11. {
  12. if (VIPS_INIT (argv[0]))
  13. vips_error_exit (NULL);
  14.  
  15. if (argc != 3)
  16. vips_error_exit ("usage: %s input-file output-file", argv[0]);
  17.  
  18. VImage in = VImage::new_from_file (argv[1],
  19. VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL));
  20.  
  21. double avg = in.avg ();
  22.  
  23. printf ("avg = %g\n", avg);
  24. printf ("width = %d\n", in.width ());
  25.  
  26. in = VImage::new_from_file (argv[1],
  27. VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL));
  28.  
  29. VImage out = in.embed (10, 10, 1000, 1000,
  30. VImage::option ()->
  31. set ("extend", "background")->
  32. set ("background", 128));
  33.  
  34. out.write_to_file (argv[2]);
  35.  
  36. vips_shutdown ();
  37.  
  38. return (0);
  39. }
Add Comment
Please, Sign In to add comment