How do I load an LCR image from my server using AlamofireImage? - alamofire

I'm trying to load an LCR image for use as a collection view cell image using AlamofireImage but nothing is showing up.
cell.imageView.af_setImageWithURL(NSURL(string: "http://www.example.com/MY_LCR_IMAGE.lcr")!)
If I use https://placehold.it/500x500 as the URL string (a PNG), it works. And the same LCR file, loads fine in my TVML/TVJS app. So I know the problem is not the LCR file or generally with how I'm attempting to load the image using af_setImageWithURL.
I'm guessing that I need to support the correct MIME type for an LCR image. When I check the MIME type of my LCR file, it is application/octet-stream. The AlamofireImage documentation says:
If the image you are attempting to download is an invalid MIME type
not in the list, you can add custom acceptable content types using the
addAcceptableImageContentTypes extension on the Request type.
So I've included the following line before I attempt to call af_setImageWithURL.
Request.addAcceptableImageContentTypes(["application/octet-stream"])
I still end up with no images.

There was a bug in AlamofireImage that it wasn't using the acceptableImageContentTypes for af_setImageWithURL. AlamofireImage 2.2.0 fixes that.

Related

Replacing Absolute file path by Resource file path

I created an add-in to an existing software (Revit) and I want to embed an image (my company's logo) in the add-in's button.
Here is my current code for it:
'Set the large image shown on button
Dim uriImage As New Uri("\\10.8.60.3\Shared\REVIT\FSElogo.png")
Dim largeImage As New BitmapImage(uriImage)
MainButton.LargeImage = largeImage
It works pretty well and the logo is correctly displayed, however it requires the computer to have access to the server located at \\10.8.60.3. When working from home, we do not have access to this server and Revit throws an error when starting because of it.
So I tried adding the FSElogo.png file to my VB.Net project as a Resource and then tried to use My.Resources to access the image, effectively removing the need for an external image to be used.
Well, I can't get it to work.
I tried replacing the code above by
MainButton.LargeImage = CType(My.Resources.ResourceManager.GetObject("FSElogo.png"), Windows.Media.ImageSource)
But it doesn't work. It doesn't throw an error, but no image is displayed on the button.
If I don't cast my Object to an ImageSource I get an implicit conversion from Object to Image error, and I'm not even sure my ResourceManager is even really returning the object FSElogo.png.
What am I doing wrong here?
I am using the VS provided button with the .BackgroundImage property. Notice that the extension of the file is not included in the resource identifier. If this doesn't work, you will have to explain exactly how you added the resource to your project.
MainButton.BackgroundImage = My.Resources.FSElogo

mPDF missing non-local images

I am generating PDF from HTML using mPDF 5.7. The generated PDF is fine when generated locally, but on server, the images are not getting rendered completely soon enough, and hence PDF is missing all images.
Has anybody encountered this issue?
Whats the solution for this?
Yes, if the images are PNG, you need to install the php-gd extension, because mPDF needs it to render alpha maps (transparencies of the images).
The issue can be debugged by setting up a debug flag/option for your script, and adding code like
if ($debug) {
$mpdf->debug = true;
$mpdf->showImageErrors = true;
}
then you'll be able to see the actual error that caused the missing images
which is
mPDF error: IMAGE Error (https://url.to.server/image.png): GD library required for PNG image (alpha channel)
(actually, there will be square icons with an X, like in old InternetExplorer "missing image" style).
You can add GD extension to composer.json, see this answer

Getting a handle to dojo's uploader filelist

We are using dojo's dojox.form.uploader.FileList in our application to show the progress of file upload. But it shows the name of the file, type extension by default. We could not see any settings to hide it or getting a handle to that. Is it possible to get a handle to that object which has file name, size and extension? Could you please help us?

Photoshop CS4 variable relative path not working

In Adobe Photoshop CS4, I'm trying to use variables and data sets to dynamically replace images listed on a .csv file.
When I tried to use the relative path of the images, the program throws an error "Could not apply data set because the replacement file was not found"
But according to an article in the adobe website, it should work.
Can anyone help?
Most of the time this kind of errors comes from the fact that ExtendScript is struggling with backslashes. Makes sure you escape your paths before using them. Or convert them to forward slashes:
var cleanFilePath = myFilePath.replace(/\\/g, "/");

Detecting corrupted jpg files before or during upload

I have an ASP application that uses ASPImage.Image to resize the uploaded image and then save the file to the server and save it in the database. However, it appears that if a user uploads a corrupted file the resulting image is blank white image.
I need a way to check if the file is corrupted before the image is passed to ASPImage.Image, that will then inform the user that the file is corrupted.
Can this be done with javascript, vbscript or ASPImage.Image itself?
Any assistance would be greatly appreciated.
Best Regards,
Paul Jacobs
There is no way to detect a corrupt image in either javascript or vbscript - you will need to try using ASPImage.Image directly.
It has an Error property, this will probably have an error detailing that a corrupt file has been loaded - did you try that? That is, if it is populated, chances are that the file was corrupt.
Additionally, the LoadImage method returns a boolean - I assume it will return false if the image couldn't be loaded due to corruption.
You can use the code here: http://forums.aspfree.com/code-bank-54/pure-asp-upload-script-with-additional-features-94647.html
Then check the image Width and Height - if 0 it means the uploaded file was not a valid image.
This is pure classic ASP code without third party components.