I want to resize the img to 90x90 by using the following code but the img is uploaded but is not resize..
$image = 'the path to the img';
/*** a new imagick object ***/
$im = new Imagick();
/*** ping the image ***/
$im->pingImage($image);
/*** read the image into the object ***/
$im->readImage( $image );
$im->thumbnailImage( 90, null );
$im->setImageFormat( "png" );
/*** write image to disk ***/
$im->writeImage( "tmp/spork.png" );
$im->destroy();
I change the code to $im->cropThumbnailImage(90,90); but still it dosent work.
There is nothing that stands out to me in the code you posted, however looking at the manual page for thumbnailImage, a lot of the comments suggest other approaches which are claimed to be better for various reasons:
http://www.php.net/manual/en/imagick.thumbnailimage.php
On the website you found the code there is a method to display any errors using try and catch; add those and see if you get an error.
Is the save folder really tmp? Is it CHMOD 755 or 777?
Related
The WebGL sample code to show custom markers is very simple but it does not work. I am interested in getting it to run on a local server successfully.
Here is the source:
https://examples.webglearth.com/#markers
and the line with the sample code that does not work:
var markerCustom = WE.marker([50, -9], '/img/logo-webglearth-white-100.png', 100, 24).addTo(earth);
It works perfectly on their website but not on my local server.
And here is my code:
// car location
var markerCustom = WE.marker([33.827284, -87.538893], 'images/car_west_small.png', 128, 125).addTo(earth);
No matter what I do, I always see the blue default blue marker. the file exists in the path and I tried varying the size to see if it was an issue with its size but still the same.
For another test I did, I also copied the original line and the original png to my local server.
var markerCustom = WE.marker([50, -9],'/img/logo-webglearth-white-100.png', 100, 24).addTo(earth);
I changed the Lat/Long to and the path
var markerCustom = WE.marker([33.827284, -87.538893], '/images/logo-webglearth-white-100.png', 100, 24).addTo(earth);
I made sure that http://localserver/images/logo-webglearth-white-100.png downloads the png correctly and it did.
Then I launched the page and I still got the issue.
How can I fix it?
I'm trying to submit form data and upload images from React Native app to CodeIgniter backend server. I'm choosing the images from react-native-image-crop-picker and only the data is sent and saved. But not the image is uploaded. I have tried this using Postman and it works perfectly.
I see that form.append() has 3 parameters. I checked the Postman request code, and it shows like this
data.append("attach_report", fileInput.files[0], "...3539240198157045_n.jpg");
My problem is, what's the datatype of fileInput.files[0] in this? Thanks in advance
Finally I found an answer for this. I have seen that the file returns from react-native-image-crop-picker is almost a File object. So I just edited the file like below.
// image is react-native-image-crop-picker returning file
image.uri = image.path;
image.name = "TEST.jpg";
image.type = image.mime;
image.dateModified = new Date();
Then,
const f = new FormData();
f.append('attach_report', image, image.uri);
f.append('user_id', 1);
Then submit the form. It works in my scenario...
I am trying to serve a PDF by adding watermark to it. I am using the image-watermark package for it
let option ={'text' : 'hello','color' : 'rgb(154, 50, 46)'};
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', 'attachment; filename=test.pdf');
fs.createReadStream(watermark.embedWatermark('/pdf/js_tut.pdf', option)).pipe(res);
I am confused at what i did wrong? I am getting a 500 error. did I put the path name wrong? I have a public folder inside which I have a pdf folder inside which i have js_tut.pdf
Looking at the source code for the function embedWatermark, it doesn't actually return anything. You can see that here.
There is not a single return statement anywhere there.
So essentially what you're doing is this:
fs.createReadStream(undefined).pipe(res)
Which is likely why you're getting 500.
I'm using the Google Drive API where I can gain access to 2 pieces of data that I need to display a jpg file oin my program. WebViewLink is the "large" size image while thumbnailLink is the "thumb" smaller size of the same image.
I'm having an issue with downloading the WebViewLink that I do not have with the thumbnailLink. Part of my code calls either exif_imagetype($filename) or getimagesize($filename) so I can retrieve the type, height & width etc for the $filename. This is successful for the thumbnailView but not the WebViewLink...
code snippet...
$WebViewLink = "https://drive.google.com/a/treering.com/file/d/blablabla";
$type = exif_imagetype($WebViewLink);
--- results in the error
"PHP Warning: exif_imagetype(): stream does not support seeking..."
where as...
$thumbnailLink = "https://lh6.googleusercontent.com/blablabla";
$type = exif_imagetype($thumbnailLink);
--- successful
where $type = 2 // a .jpg file
Not sure what I need to do to gain a usable WebViewLink... maybe use the "export" function to copy to a file on my server that is accessible, then use that exported file for the functions that fail above?
Thanks for any help.
John
I think you are using the wrong property to get the image of the file.
WebViewLink
A link for opening the file in a relevant Google editor or viewer in a browser.
thumbnailLink
A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours.
You can try using the iconLink():
A static, unauthenticated link to the file's icon.
Sample image of thumbnailLink:
Sample image of a iconLink:
It will still show relevant image about the file.
Hope it helps!
I uploaded image via paperclip so it's uploaded then after I will remove that image manually so now in our table entry is there that image is uploaded but in our system that image is not found. because we remove that image manually. In this case I want to display a default image if image is uploaded on server but not present in server.
My Image is stored in Amazon
Thanks In Advance.
Now, I Fix that issue by using following code
require "net/http"
url = URI.parse( image_path )
req = Net::HTTP.new(url.host, url.port)
begin
res = req.request_head(url.path)
rescue
end
Hope, This will help you in you feature