coldfusion imageNew error: Unsupported Image Type - coldfusion

I am trying to use the ImageNew function (coldfusion 8) to create an image object with a image URL link, e.g. <cfset myImage=ImageNew(evaluate( "http://.../../1.jpg" ))>
There are many links there and most of them are good, but for some of the image links, I got an error when I call the ImageNew function: An exception occurred while trying to read the image. javax.imageio.IIOException: Unsupported Image Type
Does it have something to do with the size of images? Does anybody have any idea?
Many thanks
Results: Finally, it's the CMYK/RGB issue. It seems CF8 has trouble in dealing with CMYK and CF8 doesn't support convertion from CMYK to RGB. I use ImageMagic to do the convertion.

To be fair, I have this issue sometimes. I don't think it has anything to do with your code, coldfusion's image processing utilities either cannot process a perfectly valid image, or they choke on an image that is not up to standards. When this happens it is typically a client uploading an image and my system throws an error. They send me the file, I resave it out using photoshop or something like that, and poof, coldfusion likes it.
The only solution I know if this is the problem, is to use a third party image processor instread of coldfusion's built in functions. I used to use cfx_imagecr
http://efflare.com/products/cfx_imagecr/
But that is not the only solution out there.

Related

PowerBI API ExportToFileInGroup, PNG format doesn't work, PDF, PPTX works correctly

I have a problem with the ExportToFileInGroup API method. According to documentation, PowerBI reports can be exported to a few different formats, for me the most useful are PPTX, PDF, and PNG
(https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-to-file-in-group#fileformat).
PPTX and PDF work fine but PNG throw exception. And that exception looks like licence problems "Operation returned an invalid status code 'Forbidden'" - I know that it is not exactly what it means but I noticed that for MS that often means that you didn't pay for that functionality. Is that possible that png format needs some extra licence?
Unfortunately, I need an image format to push that as a slack message and have an immediately preview.
I'm in the same boat - PDF and PPTX exports both work, but for PNG I get a 403-Forbidden response.
Found this: https://community.powerbi.com/t5/Developer/quot-Export-report-to-image-is-disabled-on-tenant-level-quot/m-p/1187677
...which indicates a tenant-level setting must be enabled, and the default is disabled. I'm not a tenant admin, so I don't know if this is the solution; will probably take me days get that turned on (assuming it exists), but I figured I'd share this in case it helps.

why is my libharu pdf oversized with .png images?

I am creating a pdf using libharu in C++ (compiled as a .cgi) that features .png images.
The code is fine, but my pdf's are ridiculously oversized.
Each page features one image of around 30kb and around 4 text characters in libharu's system font. If I open a 20 page output file of 25mb and "print" it to a file in my operating system it becomes 256kb or so with no visible change to the images.
I think the issue is related to libharu because this guy see's it too, here. He is using php so, libharu as a compiled .cgi. (my C++ code is also compiled .cgi, linked to libharu).
Another guy here on stack overflow has also seen size issues with libharu, but his problem does not mention anything to do with .png so it may be unrelated.
Code for reference:
WorkingGraphic = HPDF_LoadPngImageFromMem ( *gPdfPtr,
PngAssets[AssetIndex], //Image data ptr
PngSizes[AssetIndex]); //data length
//Render Appropriate
HPDF_Page_DrawImage (*BlitParams->page,
WorkingGraphic,
BlitParams->OutputRect->X,
BlitParams->OutputRect->Y,
BlitParams->OutputRect->Width,
BlitParams->OutputRect->Height);
Does anyone know how to drive libharu so it creates sensible sized pdf's when you use .png images?
Right I don't know how to remove a question but maybe this info will be useful to others anyway.
I may have had the same issue as this fellow here where I have duplicated this answer.
What I needed to do was enable compression of the .pdf, which I had not done.
Documentation link
C Code:
HPDF_SetCompressionMode (pdf, HPDF_COMP_ALL);
It's because I didn't do enough research to know that .pdf format does not natively support .png, or if it has been updated to do so, libharu still doesn't. So, this option tells libharu to use zlib to zip compress everything it can, including your images.
The implementation is not perfect (you will still see a size difference if you zip your output .pdf) but it is acceptable for my use case.
If you don't need the full-size image in the PDF, you can reduce the image to a thumbnail using GDI+ APIs, equal in size to however big you want the image to appear in the PDF.
Save the scaled PNG to a temporary file, and pass the thumbnail PNG to Haru PDF. This will reduce the size of the PDF file.
The image will be pixellated when the viewer zooms in.

og:image is not being fetched correctly by Facebook on liking or sharing

I'll try to be direct explaining my problem:
When liking/sharing an article from my website (http://www.radiopico.com) og:image does not work well (you can try with this url for example:http://www.radiopico.com/index.php?n=noticias&menu=noticias&id_noticia=14350)
on the debugger I always get the corret image url
It never shows the image
If I click the image I get a not found error.. if I copy the url and past it on the address bar I get the image
Sometimes it says image is to small.. it is wrong, because it is very larger then the minimum sizes facebook encourage. Also there is no ratio problem
When I try to post the address on facebook it never shows the picture
I have tried to add a time var (?T=...) after the address to make sure it is not caching
I have put multiple og:images.. still does not works.
I have read and tried all the "tricks" I find here (Stackoverdlow) or on google
Thanks for your support and best wishes on resolving this mystery
I notice that your image is technically not defined at 72 dpi, but rather at 300 dpi:
I cannot say definitively that this would cause your problem. Browsers are generally smart enough to display an image at 72 dpi (using the pixel dimensions) regardless of the "Resolution" that is defined within the image. However, it might be worth re-saving the image with the resolution correctly set for the web at 72dpi. Perhaps Facebook is getting confused about the image size due to the resolution setting.
Also, just to eliminate potential problems with the image, if you have Photoshop, use the Save for Web command to re-save the image, which will automatically define the re-saved image at 72dpi AND save it without a built-in preview, which you should always do for the web anyway to reduce file size. Then try again. Again, I'm not sure that these suggestions will work, but it seems like a good idea to eliminate the resolution, embedded preview and potential issues with the original file by re-saving.
Debuging your link
I see linter response is 206.
I don't know if it can help u but I've found this
check it out ;)

ColdFusion IsImageFile fails for jpg file

2 jpg images that look exactly the same (failing image above, no.jpg, resaved as yes.png) but one is not an Image according to IsImageFile function.
Run this code
#IsImageFile("http://fdiapp.com/ini/cms/file_uploads/yes.jpg")#
**
#IsImageFile("http://fdiapp.com/ini/cms/file_uploads/no.jpg")#
I think the problem is that is a CMYK jpeg. ColdFusion 9 uses ImageIO internally, which afaik only supports RGB. (While some of the java suggestions in that thread do work from ColdFusion - the colors in the resulting image are skewed.) What is probably happening is that ImageIO fails to even load the image file and that is why IsImageFile returns "no".
FWIW, IsImageFile returns "yes" in ColdFusion 10. However, it still has issues with CMYK. For example if you try and read the image, the final colors are all wrong ...
I think your best bet is to run it through a tool like ImageMagick and convert it to a format ColdFusion can handle properly.

How to verify the integrity of a image file in c++ or python?

I want to check whether the images is downloaded completely. Is there any library to use?
The images I want to verify including various formats such jpeg, png, bmp etc.
The standard go-to library for that kind of thing in Python is the Python Imaging Library (PIL).
I have used Pyhton Pillow module (PIL) and Imagemagick wrapper wand (for psd, xcf formats) in order to detect broken images, the original answer with code snippets is here.
I also implemented this solution in my Python script here on GitHub.
I also verified that damaged files (jpg) frequently are not 'broken' images i.e, a damaged picture file sometimes remains a legit picture file, the original image is lost or altered but you are still able to load it.
I quote the full answer for completeness:
You can use Python Pillow(PIL) module, with most image formats, to check if a file is a valid and intact image file.
In the case you aim at detecting also broken images, #Nadia Alramli correctly suggests the im.verify() method, but this does not detect all the possible image defects, e.g., im.verify does not detect truncated images (that most viewers often load with a greyed area).
Pillow is able to detect these type of defects too, but you have to apply image manipulation or image decode/recode in or to trigger the check. Finally I suggest to use this code:
try:
im = Image.load(filename)
im.verify() #I perform also verify, don't know if he sees other types o defects
im.close() #reload is necessary in my case
im = Image.load(filename)
im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
im.close()
except:
#manage excetions here
In case of image defects this code will raise an exception.
Please consider that im.verify is about 100 times faster than performing the image manipulation (and I think that flip is one of the cheaper transformations).
With this code you are going to verify a set of images at about 10 MBytes/sec (modern 2.5Ghz x86_64 CPU).
For the other formats psd,xcf,.. you can use Imagemagick wrapper Wand, the code is as follows:
im = wand.image.Image(filename=filename)
temp = im.flip;
im.close()
But, from my experiments Wand does not detect truncated images, I think it loads lacking parts as greyed area without prompting.
I red that Imagemagick has an external command identify that could make the job, but I have not found a way to invoke that function programmatically and I have not tested this route.
I suggest to always perform a preliminary check, check the filesize to not be zero (or very small), is a very cheap idea:
statfile = os.stat(filename)
filesize = statfile.st_size
if filesize == 0:
#manage here the 'faulty image' case
You can guess by attempting to load the image into memory (using PIL or somesuch), but it's possible that some images could be loaded ok without being complete - for example an animated GIF might load fine if you have the header and the first frame of the animation, and you won't notice that later frames of the animation were missing.
A more reliable approach would probably be to use some out-of-band communication, like rather than watching a folder and processing new files as soon as they exist, find some way of hooking into the downloader process and getting it to give you a signal when it decides it is ready.