How to define content type when an loading image in as3 flex project? - apache-flex

in flashCS3.app i think all you have to do is:
var thumb_url = my_images[i].#URL;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
but i am using flex + as3project.
how can i translate?
do i need some sort of bitmapdata class or is there a more transparent translation?
the error i get is something along the lines of "content type undefined".
thanks,
jml

I guess, it'd help a lot, if you could provide a URL where it doesn't work ...
you cannot define the content type ... the content type should be defined by the server, in a HTTP response header ... however flash player usually ignores it and looks at the starting sequence to determine the loaded content type ...
as just_a_dude mentioned, the error you get, appears, when the file type is not supported ... what kind of image are you loading?

it looks like it was as simple as a bunk link.
sorry for the noise; i had a mal-formatted PHP string that was calling an image up.

Related

How do I extract a jpeg's EXIF thumbnail using ImageSharp?

I am trying to extract thumbnails from source jpegs and save them to the file system, using the C# ImageSharp library. I see there is some mention of it in the intellisense for the component:
SixLabors.ImageSharp.Image.Metadata.ExifProfile.CreateThumbnail()
...but I can't seem to find any documentation for it or examples to call it correctly.
I did find this:
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
//method code:
Image<TPixel> thumbnail = image.Metadata.ExifProfile.CreateThumbnail<TPixel>();
https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Metadata.Profiles.Exif.ExifProfile.html
...but I need to find where the TPixel type is to get it to work. VisualStudio doesn't recognize it and I can't seem to find a namespace or use it correctly:
"The type or namespace name 'TPixel' could not be found (are you missing a using directive or an assembly reference?)"
Legacy Windows .NET Framework could do this for System.Drawing.Image.Image.GetThumbnailImage() and it worked pretty well.
EDIT: Using tocsoft's answer, I changed the code to:
if (image.Metadata.ExifProfile != null)
{
Image<Rgba32> thumbnail = image.Metadata.ExifProfile.CreateThumbnail<Rgba32>();
thumbnail.Save(thumbnailPath, encoder);
}
...however, the image.Metadata.ExifProfile is null, which is unexpected since I know these source images have EXIF data.
EDIT: Actually, it's working now. Success! Thank you!
TPixel would be any of the pixel formats in the SixLabors.ImageSharp.PixelFormats namespace. But unless you are planning on interoperating with other systems that require the pixel data layed out in memory in specific ways you will likely just want to use Rgba32
Image<Rgba32> thumbnail = image.Metadata.ExifProfile.CreateThumbnail<Rgba32>();

Are there Tags that could solve this?

New to coding, trying to see what/if Tags would make this code work
So I'm a beginner with basic understanding and more of a Graphics/ Designer than code based. I found a codepen by WEDOO that has exactly what I need and want to try to just swap my "animationData" to see if I can get it to work and then modify it as needed for my test (will be assign the button code to various objects for the SVG). I Can't seem to find the right "Tags" or determine if its referencing an external script...I'd image it just needs the right information to function...is that correct?
Thanks in advance!
var animation = bodymovin.loadAnimation({
container: targetAnim,
path: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/914929/data-testo4.json...
My output from BodyMovin in a JSON file:
var animationData =
{"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
Does it make sense to think that I need replace the var animation with info that should be the targetAnim with the code in the JSON file? So far put the var animationData breaks things and does nothing (visually).
The bodymovin.loadAnimation can be passed either a URL to a Bodymovin JSON via the path option OR you can pass the animation JSON inline by setting the animationData option instead.
In you case it would end up looking something like:
var animation = bodymovin.loadAnimation({
container: targetAnim,
animationData = {"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
...
})

import a google static map directly in fpdf

I wanted to place a google static map in a pdffile generated by using the fpdf extension.
and used code to make a tempfile first. Using this code. However I run into an error ('can't open image file').
// define the mapurl
$fullURL = 'http://maps.googleapis.com/maps/api/staticmap?center=Amsterdam&z=14&size=100x100&sensor=false';
// create a tempfile
$tempF = tmpfile();
fwrite($tempF, file_get_contents($fullURL));
//Rewind to the start of file
rewind($tempF);
// place the image in the pdf.
if (!empty($tempF)) {
$this->Image($tempF,$start_x, $this->GetY(),0,100);
}
fclose($tempF); // remove the tempfile
Note: OP's own answer extracted from the question.
Then I found out it can be done much easier... I don't need to use a tempfile. If I put the url in the image variable and give a format the thing works in two lines.. I don't use the height and width parameters in fpdf because they stretch the image into a unreadable form.
$fullURL = "http://maps.googleapis.com/maps/api/staticmap?center=". \
$row-Google_coor."&zoom=10&size=2200x200\
&markers=color:blue%7Clabel:D%7C".$row->Google_coor;
$this->Image($fullURL,$start_x, $this->GetY(),0,0,"PNG");
Saddly when using this function sometimes the program returns an error. The image could not be found. But when I put the url string in the browser the image shows up fine. Hopefully this is also a minor fallback.
Lets see if I find a solution on the google apis site https://developers.google.com/maps/documentation/staticmaps/?csw=1
For what it is worth I had this problem as well, I found that my server had an outgoing connections manager, this would automatically block the request, I had to add the ip, once this was done it worked fine.
I had a problem similiar to the OP's. I was getting an error when using FPDF and trying to get the static map image from Google Maps and into my PDF. I was getting "FPDF error: Missing or incorrect image file". What I did is to register in the Google Developer Console and get an API Key, just like they say in the documentation
Hope this helps.
You can download the image and use it with fpdf
$url ="https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=".$googleApiKey;
$img = __DIR__.'/img/map.png';
file_put_contents($img, file_get_contents($url));
$pdf->Image($img,null,null,170);
Hope that this will be helpful

Loader for functions?

I am attempting to monitor the progress of an image scroller I've built and all of the images (thumbs) load separately. What would be the best way of figuring out what the total progress of the images that are loading?
I was thinking it would be cool to use a generic loader and apply it to a function such as
myScroller.loadImages();
But I haven't seen any examples of that.
I did come across this thread:
but I'm not sure if it really addresses the issue I'm up against or not.
Thanks for any thoughts or expertise.
jml
Hey there, I would lean towards the 3rd. option mentioned by maxmc. I'd have an XML with the info. of all the images I want to load (e.g. name, size, etc); this way I will know ahead how many images are going to be loaded, if I want to measure the overall progess based on the number of the remaining images, but also the total bytes I have to load in case I want to monitor the overall progress in terms of remaining bytes to load.
This XML of course could be created on demand; you just need to create a script that gets, from flash, the folder or location which you want to load images from, so it reads it, get the necessary info about the images and returns to flash the result as XML so it can proceed with the load images process.
the problem is that you only know the size of an image if you start loading it so there are three options i guess:
1) start loading each of the image and stop immediately after you get the size. the disadvantage is that you double the requests.
2) when you start to load the first image, multiply it's size with the number of images. disadvantage is that this is inprecise.
3) if you define the images somewhere outside your app for instance in an xml you could add some kind of filesize attribute and when you compile your app inject the sizes via some custom ant task into the xml.
i favour option 3.
Depending on the scale of your app you could look into the bulkloader library. It's not exactly lightweight, about 16kb I think, but if you're loading quite a few images then that shouldn't be too much of an impact. Check the site for detailed instructions but you do something like this:
private var $loader : Bulkloader = new BulkLoader( "ExampleLoader" );
private function startLoad() : void
{
$loader.add( "image1.jpg", { id : "image1", type : "image" });
$loader.add( "image2.jpg", { id : "image2", type : "image" });
$loader.add( "image3.jpg", { id : "image3", type : "image" });
$loader.addEventListener( BulkLoaderEvent.COMPLETE, loadComplete )
$loader.start();
}
private function loadComplete( e : BulkLoader ) : void
{
var thumbNail : ThumbNail = new ThumbNail( $loader.getBitmap( "image1" ) );
}
Not sure if that's exactly right but you should get the idea.
Rich

How to read the filter variable in a php code block in views 2?

I'm trying to create an img link manually with php in the header field of a view, in drupal 6. I need to read the value of one of the filters, but can't find the right variable to read. I thought I could print_r($view->filters) but it didn't give me anything, and I eventually found out that isset($view) is false.
Am I looking the wrong way?
The context I'm writing in is the header field of the view, with php code as input format. Do I have to "enable" the $view variable for reading in this context somehow?
OK I found it, it was really easy:
$pa_view = views_get_current_view();
$pa_nr = $pa_view->display['default']->display_options['filters']['field_nummer_value']['value']['value'];

Resources