2 4961
On Thursday 18 August 2005 10:07 am, tv****@gmail.co m wrote: I have been trying to add a watermark to a jpeg using PIL, but the watermark has a black box around it. I looked at
[...] but I think these only refer to gif or png. I know jpegs really do not support transparency, but is there some way to take a watermark in a non jpeg format and add it to a jpeg without that box appearing around it?
Jpeg is a lossy compression format. You shouldn't do image processing
in such a format at all. Convert the data to PNG, do your processing,
and convert back to JPG for delivery. PIL can do that.
--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com
You need to pass a mask in when you paste in the watermark.
see the documentation for the paste method at http://effbot.org/imagingbook/image.htm
for more information
This should at least get you started... import Image import ImageDraw import ImageFont import ImageEnhance im=Image.new('R GB',(300,300),( 0,0,0)) font=ImageFont. truetype('verda na.ttf',12) wm=Image.new('R GBA',(100,50),( 255,255,255)) im=Image.new('R GB',(300,300),( 255,255,255)) draw=ImageDraw. Draw(wm) draw.text((0,0) ,'Watermark',(0 ,0,0),font) wm.show() en=ImageEnhance .Brightness(wm) mask=en.enhance (0.5) im.paste(wm,(25 ,25),mask) im.show()
Here, the alpha channel of 'mask' is used as the mask.
max This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Derek |
last post by:
I wanted to know if anyone had any insight or sample code of creating
an AVI file from a directory of JPEG images. I have read the thread
that that speaks about creating a MOV file from JPEG images but I need
to create a AVI file. I also am aware of the sample code provided by
sun in the following link that shows how to create a MOV file from
JPEG images (http://java.sun.com/products/java-media/jmf/2.1.1/solutions/JpegImagesToMovie.html).
...
|
by: Mr. x |
last post by:
Hello,
I would like that my image's background color will be transparent.
What I have is only paintbrush.
My image is *.jpg format (I have tried to save it as *.gif format, and I got
less quality),
and I don't know how to make the background.
In every tool I open the image (html, flash, etc...) I see the original
background color, and not the transparent color.
|
by: Chamomile |
last post by:
Does anyone know if its possible to set imagecreatetruecolor() to initialise
with transparency
rather than black?
Maybe a cunning work-around?
|
by: tommaso.gastaldi |
last post by:
In a previous post I have been asking about a way to test Alpha
Transparency.
Bob and Michael have kindly provided some ideas.
Here I would like to share the function I have prepared, for the
purpose to improve it.
Frankly, I am not clear about the exact meaning of some pixel format
(max, gdi, etc.) and I hope I have put them under the right "case". I
have made only some superficial test and it seems to work.
Note that the purpose is...
|
by: tshad |
last post by:
I am trying to set up an Image authorization where you type in the value
that is in a picture to log on to our site.
I found a program that is supposed to do it, but it doesn't seem to work.
It should put a blue and yellow box on the page with "This is a test" as
part of the picture. But what I get is a broken Gif.
The other problem is that I can't view the source???? The view source is
disabled for this page. What causes this?
| |
by: ameshkin |
last post by:
Hi,
Im pretty new at PHP and need help with something very simple. I wrote
a function which watermarks an image. The function works, but i can't
figure out how to output the image into a file.
I want to feed this function a URL, $image..and at the end of this
code, I want to overwrite the $image file with the new watermarked
$image file. Im getting an error stating that this file cannot be
opened.
|
by: Chuck Anderson |
last post by:
Is it possible to overlay a transparent watermark on an image -
dynamically?
I'd like the result to look like this example:
<http://www.cycletourist.com/temp/photo.php>
That is a bit of overkill, but you can see what I mean. The watermark
image (a png image) is included separately below the photo.
I tried using a class from phpclasses.org
<http://www.phpclasses.org/browse/package/1580.html...
|
by: Tem |
last post by:
I need to write a custom handler when the handler is accessed, it returns
the photo in jpg with 2 lines on the bottom of the image.
lower left "Taken by"
lower right "January 2 2008"
This is what I have so far...
public class certificate : IHttpHandler {
public void ProcessRequest (HttpContext context) {
|
by: rfr |
last post by:
Apparently the Transitional Doctype kills this script because the script
does not make proper use of units like "px".
It works well without a doctype statement. But once someone adds a
transitional doctype, the js script no longer works.
Can someone familiar with javascript bring it up-to-date so that it works
with current doctypes and post it here for others to make use of?
The whole HTML document including the js scrip follows (...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |