Databases Reference
In-Depth Information
Examples of Transformations
We will now discuss a few transformation examples. We will start by changing the
field type of our
cover_photo
field.
Clickable Thumbnail (.jpeg or .png)
We change our
cover_photo
field type from
BLOB
to
MEDIUMBLOB
to
ensure that we can upload photographs that are bigger than 65 KB to it. We then
enter the following attributes:
Here, the options are presented as
width,height
. If we omit the options, the default
values are
100,100
. The thumbnail generation code preserves the original aspect
ratio of the image, so the values entered are the
maximum
width and height of the
generated image. We then upload a
.jpeg
file in a cell (using instructions from
Chapter 6). As a result, we get the following in
Browse
mode for this table:
This thumbnail can be clicked to reveal the full-size photograph.
The thumbnail is not stored anywhere in MySQL, but
generated each time we go into
Browse
mode for this set
of rows. On a Pentium-III 500 MHz server, we commonly
experience a generation time of 0.5 to 1 second per image.
For a
.png
file, we have to use
image/png
as the MIME type, and
image/png:
inline
as the transformation.
Search WWH ::
Custom Search