Merge branch '8.10'
This commit is contained in:
commit
c3c9f281c0
@ -10,11 +10,13 @@
|
||||
- add _source load support for pdfium
|
||||
- add "seed" param to perlin, worley and gaussnoise
|
||||
|
||||
18/12/20 started 8.10.5
|
||||
- fix potential /0 in animated webp load [lovell]
|
||||
22/12/20 start 8.10.6
|
||||
- don't seek on bad file descriptors [kleisauke]
|
||||
- check for null memory sources [kleisauke]
|
||||
|
||||
18/12/20 started 8.10.5
|
||||
- fix potential /0 in animated webp load [lovell]
|
||||
|
||||
14/12/20 started 8.10.4
|
||||
- fix spng detection
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<refsect3 xml:id="average-a-region-of-interest-box-on-an-image">
|
||||
<title>Average a region of interest box on an image</title>
|
||||
<programlisting language="python">
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import pyvips
|
||||
@ -31,7 +31,7 @@ height = 64
|
||||
|
||||
image = pyvips.Image.new_from_file(sys.argv[1])
|
||||
roi = image.crop(left, top, width, height)
|
||||
print 'average:', roi.avg()
|
||||
print('average:', roi.avg())
|
||||
</programlisting>
|
||||
</refsect3>
|
||||
<refsect3 xml:id="libvips-and-numpy">
|
||||
@ -40,7 +40,7 @@ print 'average:', roi.avg()
|
||||
You can use <literal>pyvips.Image.new_from_memory()</literal> to make a vips image from an area of memory. The memory array needs to be laid out band-interleaved, as a set of scanlines, with no padding between lines.
|
||||
</para>
|
||||
<programlisting language="python">
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import time
|
||||
@ -50,7 +50,7 @@ from PIL import Image
|
||||
import numpy as np
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('usage: {0} input-filename output-filename'.format(sys.argv[0]))
|
||||
print(f'usage: {sys.argv[0]} input-filename output-filename')
|
||||
sys.exit(-1)
|
||||
|
||||
# map vips formats to np dtypes
|
||||
@ -135,7 +135,7 @@ $ for i in {1..1000}; do cp x.tif test/$i.tif; done
|
||||
And run this Python program on them:
|
||||
</para>
|
||||
<programlisting>
|
||||
$ time ./try255.py x.tif[squash,compression=ccittfax4,strip,bigtif] test/*
|
||||
$ time python try255.py x.tif[squash,compression=ccittfax4,strip,bigtiff] test/*
|
||||
real 1m59.924s
|
||||
user 4m5.388s
|
||||
sys 0m8.936s
|
||||
@ -147,7 +147,8 @@ sys 0m8.936s
|
||||
If you wanted to handle transparency, or if you wanted mixed CMYK and RGB images, you’d need to do some more work to convert them all into the same colourspace before inserting them.
|
||||
</para>
|
||||
<programlisting language="python">
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/python3
|
||||
#file try255.py
|
||||
|
||||
import sys
|
||||
import random
|
||||
|
@ -21,6 +21,14 @@ $filename = "image.jpg";
|
||||
$image = Vips\Image::thumbnail($filename, 200, ["height" => 200]);
|
||||
$image->writeToFile("my-thumbnail.jpg");
|
||||
</programlisting>
|
||||
<para>
|
||||
You can also call <literal>thumbnail_source</literal> from the CLI, for example:
|
||||
</para>
|
||||
<programlisting>
|
||||
$ cat k2.jpg | \
|
||||
vips thumbnail_source [descriptor=0] .jpg[Q=90] 128 | \
|
||||
cat > x.jpg
|
||||
</programlisting>
|
||||
<refsect3 xml:id="libvips-options">
|
||||
<title>libvips options</title>
|
||||
<para>
|
||||
@ -263,7 +271,7 @@ $ ls -l tn_shark.jpg
|
||||
Now transform to sRGB and don’t attach a profile (you can also use <literal>strip</literal>, though that will remove <emphasis>all</emphasis> metadata from the image):
|
||||
</para>
|
||||
<programlisting>
|
||||
$ vipsthumbnail shark.jpg --eprofile srgb -o tn_shark.jpg[profile=none]
|
||||
$ vipsthumbnail shark.jpg --export-profile srgb -o tn_shark.jpg[profile=none]
|
||||
$ ls -l tn_shark.jpg
|
||||
-rw-r–r– 1 john john 4229 Nov 9 14:33 tn_shark.jpg
|
||||
</programlisting>
|
||||
@ -274,22 +282,11 @@ $ ls -l tn_shark.jpg
|
||||
<literal>tn_shark.jpg</literal> will look identical to a user, but it’s almost half the size.
|
||||
</para>
|
||||
<para>
|
||||
You can also specify a fallback input profile to use if the image has no embedded one. This can often happen with CMYK images, producing an error message like:
|
||||
You can also specify a fallback input profile to use if the image has no embedded one. For example, perhaps you somehow know that a JPG is in Adobe98 space, even though it has no embedded profile.
|
||||
</para>
|
||||
<programlisting>
|
||||
$ vipsthumbnail kgdev.jpg
|
||||
vipsthumbnail: unable to thumbnail kgdev.jpg
|
||||
vips_colourspace: no known route from 'cmyk' to 'srgb'
|
||||
$ vipsthumbnail kgdev.jpg --input-profile /my/profiles/a98.icm
|
||||
</programlisting>
|
||||
<para>
|
||||
If you supply a CMYK profile, it will be able to convert the image, for example:
|
||||
</para>
|
||||
<programlisting>
|
||||
$ vipsthumbnail kgdev.jpg --iprofile cmyk
|
||||
</programlisting>
|
||||
<para>
|
||||
(As before, the magic string <literal>cmyk</literal> selects a high-quality CMYK profile that’s built into libvips, but you can use any CMYK profile you like.)
|
||||
</para>
|
||||
</refsect3>
|
||||
<refsect3 xml:id="final-suggestion">
|
||||
<title>Final suggestion</title>
|
||||
@ -299,9 +296,8 @@ $ vipsthumbnail kgdev.jpg --iprofile cmyk
|
||||
<programlisting>
|
||||
$ vipsthumbnail fred.jpg \
|
||||
--size 128 \
|
||||
--eprofile srgb \
|
||||
-o tn_%s.jpg[optimize_coding,strip] \
|
||||
--eprofile srgb
|
||||
--export-profile srgb \
|
||||
-o tn_%s.jpg[optimize_coding,strip]
|
||||
</programlisting>
|
||||
</refsect3>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user