Comments (5)
Hello, try plain crop
. Smartcrop searches the image for features like faces or high-saturation areas and tries to centre the crop on that.
The libvips one is rather like:
https://github.com/jwagner/smartcrop.js
from pyvips.
Crop docs here:
http://jcupitt.github.io/libvips/API/current/libvips-conversion.html#vips-crop
(extract_area
is a synonym for crop
), or smartcrop docs are here:
http://jcupitt.github.io/libvips/API/current/libvips-conversion.html#vips-smartcrop
from pyvips.
Are there python bindings for vips-crop? I don't see them in the docs, nor did it work when I called it as a method.
For a better understanding of my workflow, I need resize, offset, crop, write image - in that order.
image_resize = self.original_image.resize(zoom)
image_offset = image_resize.copy(xoffset = int(x_total), yoffset = int(y_total))
image_vips = image_offset.smartcrop(self.output_raster_width, self.output_raster_height)
data = image_vips.write_to_buffer('.JPEG', Q=95)
image_bytes = PIL.Image.open(io.BytesIO(data))
image_bytes.save(p.stdin, 'JPEG')
So yes I can chain all these methods together, however, since crop is in the middle, I would have to call the pyvips version of it vs the PIL version. Any suggestions on how to improve this order of operations?
Many thanks for the help, John.
from pyvips.
Sure, it should work. I see:
john@kiwi:~/pics$ python
Python 2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.new_from_file("k2.jpg")
>>> x = x.crop(0, 0, 100, 100)
>>>
Historically, the vips operation was called extract_area
, but that caused great confusion since people expect it to be called crop
, so crop
was added as a synonym. Anyway, either should work and they do the same thing.
Your code should be:
im = pyvips.Image.thumbnail('k2.jpg', 128)
im = im.crop(10, 20, 100, 100)
data = im.write_to_buffer('.jpg', Q=95)
sys.stdout.write(data)
You seem to be saving to stdin, which puzzles me a little. Are you sure you don't mean stdout?
thumbnail
is much, much faster than new_from_file
plus resize
, since it can do tricks like libjpeg shrink-on-load. It also handles transparency correctly, so you get better quality too. It has a number of useful options, see:
http://jcupitt.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail
from pyvips.
I'll close. Please reopen if there is still a problem.
from pyvips.
Related Issues (20)
- Reading in image a second time breaks on qptiff file HOT 6
- Documentation link to conda package HOT 1
- Create svs file with image pyramid, label and macro in pyvips? HOT 4
- Image merge stitch HOT 2
- `addalpha` has different behaviour compared to C HOT 1
- Error installing pyvips on Mac OS HOT 15
- draw_rect fill error HOT 2
- creating tiles of 16bit multiband (4 band) tiff image leaves black canvas HOT 4
- class "jxlsave" not found HOT 9
- Assertion failed: sp->cinfo.comm.is_decompressor HOT 3
- Help installing pyvips for jupyter HOT 5
- `TIFFFillTile: Read error` when writing a TIFF file on a per-tile basis. HOT 2
- Thumbnail creation taking too long HOT 2
- Unable to save images when certain combinations of them are resize()'d HOT 7
- pyvips stats HOT 1
- How does composite() merge colors? HOT 8
- ICC profiles from file stream in pyvips HOT 5
- Why is error 0x7f? HOT 1
- Can libvips' stack size be modified using pyvips? HOT 6
- Unable to convert multiband image to srgb HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvips.