Python PIL: Draw text below an image - python-imaging-library

how do I draw text below an image using PIL? I have already drawn text on the image without problems and I am now trying to draw below the image without success.
My text drawing line:
draw.text((0,img.size[1]),text= mytext, font = font, fill = img.getpixel((502,10))
I am not getting any errors

Related

resize and save transparent PNG file in matlab

I have an transparent png file(colored image not black and white).I want to resize this png file and save that with transparent background.but i cant save that with transparent background.file saved with dark background.
[im,map]=imread('image.png');
im=ind2rgb(im,map);
im2=imresize(im,[200,200]);
imwrite(im2,'image2.png');
in above code image2.png saved with black background and not transparent
Additionaly you have to read the transparency (alpha) value of the Image. Then you have to scale that value as well. Then you can write the Image with the alpha value.
[im, map, alpha] = imread('image.png');
im2=imresize(im,[200,200]);
resizedAlpha = imresize(alpha,[200, 200]);
imwrite(im2, 'image2.png', 'Alpha', resizedAlpha);

How to write text inside an oval shape in Microsoft Word

I want to write a text inside oval shape and also want that text should also adapt that shape using Microsoft Word (because I only have Microsoft Word).
I am elaborating my question using this image:
I just added a label above the shape, and changed it's BackColor to the shape color, AutoSize to False,TextAlign to MiddleCenter and resized the label inside of the shape so the Text will fit on the shape.
But make sure you won't add text that has a length more than the shape width, because it will get ugly!

Swift String DrawInRect top margin

I'm trying to layout some text that is being exported as a PDF.
I'm using drawInRect(rect, withAttributes) to draw the strings, however, I'm getting a gap between the top of the rectangle the text is being drawn in, and the actual text.
Here's a screenshot, with the bounding rects stroke in red
the goal is to have the 2 "1." be top aligned, but because of that gap I can't figure out how to do that...
Thanks!

saveas white border matlab

I want to save a frame as an image in png format with saveas command. Although my image's size is 640X480 (gcf), the saved images size is 1201x901 and spaces white color.(like a bold white border).So I want the image to be saved 640x480.
I tried transparent background but it didn't work. How can I fix this problem?
F(j) = getframe(gcf);
fname='C:\...'
saveas(gcf, fullfile(fname, 'newImage'), 'png');
Try this,
set(gca,'position',[0 0 1 1],'units','normalized')
or you can try the imcropfunction.
If you aren't overlaying any graphics over the image, then save the image data directly using imwrite, rather than exporting a figure containing the image to png.
If you are overlaying graphics then the export_fig function (available for download on the MATLAB File Exchange) will automatically crop the whitespace around the figure. In this case use:
export_fig(fullfile(fname, 'newImage'), '-png', '-a1', '-native');

How to create semi-transparent image using imagemagick

I have a hex (i.e. #FF0000) color and want to generate 50% transparent 50x50 image using imagemagick from command line.
I had to figure out something similar when I was working with CSS 3 and RGBA.
convert -size 50x50 xc:'rgba(255,0,0,0.5)' red_0.5_pixel.png