I have an application written in VB6 and would like to know how I would display an image blob from postgres to VB6?
If the image blob is in one of several standard formats (BMP, JPEG, GIF, TIFF file format) you can use WIA 2.0 for this.
Get the blob as a Byte array, create a WIA.Vector object, assign the Byte array to the Vector.BinaryData property, then you can use the Vector.Picture property to retrieve a StdPicture object you can assign to an Image or PictureBox control.
This code can help if the image can be loaded to a picture box.
See the PictureFromByteStream() Function in Module1.bas
Related
I would like to insert a small image to each page in a multi-page tiff using Pillow.
But this fails:
from PIL import Image, ImageSequence
stack = Image.open(r"D:\pillow_temp\stack_example.tif") # opens an rgb multi tiff
insert= Image.open("D:\pillow_temp\insert.tif") # opens a single page rgb multi tiff
for page in ImageSequence.Iterator(stack):
page.paste(insert,(0,0))
stack.save(r"D:\pillow_temp\out_fails.tif", format="TIFF", save_all=True)
Transforming the multi-page tiff to a list and saving one changed image first followed by appending the rest of the images works but doesn't feel proper.
pages= []
for page in ImageSequence.Iterator(stack):
page = page.copy()
page.paste(insert,(0,0))
pages.append(page)
pages[0].save(r"D:\pillow_temp\out_works.tif", format="TIFF", save_all=True, append_images=pages[1:])
Is there a way to manipulate the pages directly in the PIL.TiffImagePlugin.TiffImageFile object and call im.save("filename.tiff", format="TIFF", save_all=True) directly?
All help is appreciated.
https://pillow.readthedocs.io/en/stable/reference/ImageSequence.html?highlight=multi%20tiff%20iterator#the-iterator-class
https://pillow.readthedocs.io/en/stable/releasenotes/3.4.0.html?highlight=multitiff%20image%20save#save-multiple-frame-tiff
Lets say i have an image link that is stored in mongodb as a string. The image is uploaded somewhere and is accessible. How would i be able to display this thing that holds the string as an image in the ejs or html page?
For example the schema is: User.
And the name that holds the string in the database = user.characterimg
However if i would put that just like that in a ejs file it would only show the string and not the actual image.
I found the solution:
src= <%=user.characterimg%>>
Resolved:
This had nothing to do with iTextSharp. The culprit is XMPIE and how it renders pdfs.
I'm using iTextSharp to convert .pngs to pdfs.
Here's a snippet of code:
var image = iTextSharp.text.Image.GetInstance(imageBytes);
document.Add(image);
My question is: does this actually convert the .png to a .pdf? Does it change the Mime type?
I am trying to use the converted image in XMPIE, which does not support .pngs. The "conversion" seems to work -- meaning that I get a pdf that has my image on it. But when I try to display that image in xmpie it displays all blurred out and grey. The "conversion" works with .jpegs but not .pngs.
Is there another way to convert an image (.png) to a .pdf. My code just seems to add the image to the .pdf and doesn't actually change the mime type.
How can I Load an image.Jpg using Centura?
then display it in Centura and be able to load this image as a logo in the qrp reports?
For loading the image into a centura image control by setting its property as shown in the below image.
In addition to this you can also load the image pragmatically using any of the below mentioned Sal functions,
1.SalPicSetImage
bOk = SalPicSetImage ( hWndPict, strImageBytes, nType )
Inserts the contents of a string to a picture object. The third parameter is a constant.
Parameters
hWndPict Window handle. The handle (or name) of a picture.
strImageBytes String. String buffer which stores the image bytes.
nType Number. The format of the picture contents:.Example for jpg - PIC_ImageTypJPEG
2.SalPicSetFile
bOk = SalPicSetFile ( hWndPict, strFileName )
Inserts a file's contents into a picture.
Parameters
hWndPict Window Handle. The handle (or name) of a picture.
strFileName String. The name of the file whose contents are to be inserted into hWndPict.
Steps for passing an image into Qrp
1.Declare an Object in the qrp file, as shown in the below image
2.Assign the above mentioned object to Qrp picture as shown the image below,
3.Set the above mentioned object in the output list.(in centura application)
4.Assign centura image contents into a longstring variable and set it in Input list.(In centura application)
For copying centura image contents into string variable you can use SalPicGetString().
In an asp.net mvc-2 application I need to export a view to pdf. I am using itextsharp to generate pdf. In the application I have documents which contains different instructions with instruction title and different images attached to it. I need to export all the instructions under a document to pdf. The instruction title contains bullets and numbering. It is stored in the database in html format. Also the images attached to each instruction is stored in the db in byte format. My pdf contains a table with each row representing an instruction. I am facing two basic issues in generating pdf with these data :
When I try to show the title, it is shown with html tags. In the pdf I need to show the title with bullets and numbers(ie. as entered through the editor).
I need to show byte stream images attached to each instruction in the pdf.
See the first three paragraphs of my post here for the answer to your first problem.
For your second question, iTextSharp (and more to the point, the PDF format) supports several formats. For formats not supported you can use the .Net Framework to convert many of them to a usable format. (The easiest to work with is probably JPEG.)
See this post if you need to know hot to get raw bytes from a database. Once you've got bytes you can use iTextSharp.text.Image.GetInstance() which has (as of 5.1.1) 15 overloads including ones that takes raw bytes, a System.Drawing.Image and `System.IO.Stream'.