I have set up on client Jcrop and on Server a imagemagick (express.js).
Image is uploaded to server first, and then shown to the client. Client makes crop, and the following information is sent to server:
function showCoords(c)
{
// variables can be accessed here as
// c.x, c.y, c.x2, c.y2, c.w, c.h
};
I have the image stored on server ready to be cropped. Question is, if using imagemagick... how do I use those variables? Image magick has resize and crop (it has other options as well) that seem to be relevant... but it seems that I have more variables then the IM accepts.
What is going on?
You can ignore point2 (c.x2,x.y2). Jcrop is just being helpful by giving you a rectangles size (c.w,c.h), starting point (c.x,c.y), and ending point (c.x2,c.y2).
ImageMagick has it's own Image Geometry format, so you just need the size & offset (starting point).
function showCoords(c)
{
var IMGeometry = String.concat(c.w,"x",c.y,"+",c.x,"+",c.y);
//=> "175x125+50+50"
// Assuming you are using node-imagemagick
im.convert(["source.jpg","-crop",IMGeometry,"out.jpg"],function(err, stdout){
// Callback
});
}
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 want compress image when i upload image in react native i use react-native-compressor package
Image.compress(setPhoto(imageresponse.assets["0"].uri), {
compressionMethod: 'auto',
});
This is my code,
When i upload image suddenly display the error
Compression value is empty, please provide a value for compression.
i check package documentation
compress(value: string, options?: CompressorOptions): Promise
Compresses the input file URI or base-64 string with the specified
options. Promise returns a string after compression has completed.
Resizing will always keep the original aspect ratio of the image, the
maxWidth and maxHeight are used as a boundary.
I dont know how to give value, please give solution for me
I am trying to use google ml kit to process an image so i extract the left eye open probability,
but it requires the input image to be either a file,bytes or file path, see below
final inputImage = InputImage.fromFile(file);
final inputImage = InputImage.fromBytes(bytes: bytes, inputImageData: inputImageData);
final inputImage = InputImage.fromFilePath(filePath);
it requires one of those above, i am trying to use a Camera image stream to achieve this,
_cameraService.cameraController.startImageStream((image) async {
// i am trying to convert the image received here to be converted into either a File, Bytes, File path
}
ML Kit team doesn't own the flutter_mlkit repo, so please file issue at https://github.com/azihsoyn/flutter_mlkit/issues
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!
SOLVED
There was an exercise in futility.
24 hours to discover it was a comma in the wrong place.
#sysMessage.messagePictureData = Base64.strict_encode64(open(imagestring).read),
#sysMessage.messagePuzzleNumber = "#{sendPiece}"
Two things concatenated and hours lost. Thanks to those who read this.
UPDATE
I now seem to have the files being read and encoded "properly" ... in that I'm seeing what I'm expecting in terms of encoded data. But I have no idea why the JSON is coming down enclosing the data in square brackets and quotes (and adding another value!).
messagePictureData = "[\"iVBORw0KGgoAAAANSUhEUgAAANgAAADYCAYAAACJIC3tAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAMSZJREFUeNrsnQmcFOWZ/9/qqr67p+e+mJPhmINBjhkYAQFFUMEo4JGN2Rz6j8lqotnsJqtxs6sxnzWa7Gpi1jMbNcb7wFsEuQTkZm ... [LOTS OF DATA] ... JZlUmyRSYkV+5NtGf5B2KdORE1ZLMK1kCCkD5oF1I8Pl+gu22gftAT7u4/1+AiwEhfhIPFXJaMLpvZFUlRMzsUNWIyMqs/QcwcTDKlBdsNrcHOwSZ13bQd2rn49yfASGdVDzofwWIHPsXy+PDylRK1g5FIBBiJRICRSKRPyME0+klIJHIwEmlM6P8LMACzov3UuDGSEwAAAABJRU5ErkJggg==\", \"30\"]";
How do I get Objective C to just read the first part in the brackets? I'm drawing a complete blank!
ORIGINAL POST
I'm sure there are better ways, but I have a Rails Server which was encoding PNG image files from AWS and, using RABL, encoding them into JSON (with a lot of other data) which was being delivered to my iOS device and being saved as a photo in Core Data.
It was all working, but now it's not and I am wondering if someone could take a look and see where it's going wrong. Sadly, I did a bundle update on my computer and this has updated a LOT of gems and Rails itself. Sigh. I consequently have no idea if there is a problem with one of the gems (and not a highly proficient debugger to try and sort it out) or my code.
Rails Controller code:
The code looks if there is a photo held on AWS. If there is, it looks for the URL, or provides a placeholder image URL if there isn't an image. I then need it to read the file and store it in a the database for delivery.
if (#photos.approvedMainPhoto == true)
imagestring = eval "#photos.photoImage#{sendPiece}.url"
else
imagestring = "#{::Rails.root}/public/images/placeholders/smallimageplaceholder.png"
end
#sysMessage = Message.new
...
#sysMessage.messagePictureData = File.open(imagestring, "r").read,
...
if (#sysMessage.save)
[true, #sysMessage.id]
else
[false, 0]
end
RABL Code
I've stripped some of the code out but I have coded that if there is picture data (and there isn't always going to be a photo), then encode it using Base64.strict_encode64 what is held in the database for transport.
object false
node(:message) { #code }
node(:number) { #nummessages }
child #messages, :object_root => false do
node(:messagePictureData, :if => lambda { |m| m.messageText == ""}) do |m|
Base64.strict_encode64(m.messagePictureData)
end
end
This seems to be delivering something. When I ask for the output in my XCode Console ... I get something similar to:
The JSON encoded data is saying:
messagePictureData = "WyJceDg5UE5HXHJcblx1MDAxQVxuXHUwMDAwXHUwMDAwXHUwMDAwXHJJSERSXHUwMDAwXHUwMDAwXHUwMDAwXHhEOFx1MDAwMFx1MDAwMFx1MDAwMFx4RDhcYlx1MDAwNlx1MDAwMFx1MDAwMFx1MDAwMFx4ODkgLVx4RURcdTAwMDBcdTAwMDBcdTAwMDBcdTAwMTl0RVh0U29mdHdhcmVcdTAwMDBBZG9iZSBJbWFnZVJlYWR5cVx4QzllPFx1MDAwMFx1MDAwMDEmSURBVHhceERBXHhFQ1x4OURcdFx4OUNcdTAwMTRceEU1XHg5OVx4RkZceERG6qq .... [LOTS MORE] ... HhDMWJcYT5ceEM1XHhGMlx4RjhceEYwXHhGMlx4OTVcdTAwMTJceEI1XHg4M1x4OTFIXHUwMDA0XHUwMDE4XHg4OURceDgwXHg5MUhceEE0T1x4QzhceEMxNFx4RkFJSCRyMFx1MDAxMmlMXHhFOFx4RkZcdjBcdTAwMDBceEIzXHhBMlx4RkTUuDFceDkyXHUwMDEzXHUwMDAwXHUwMDAwXHUwMDAwXHUwMDAwSUVORFx4QUVCYFx4ODIiLCAiMzAiXQ==";
When I put it through the following code in Objective C:
Objective C Code:
NSLog(#"I have the message Picture Data as: %#", message[#"messagePictureData");
NSData *photo = [[NSData alloc] initWithBase64EncodedString:message[#"messagePictureData"] options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSLog(#"I have the photo data as: %#", photo);
I get the following output in the Console:
I have the photo data as: <5b225c78 3839504e 475c725c 6e5c7530 3031415c 6e5c7530 3030305c 75303030 305c7530 3030305c 72494844 ... [LOTS MORE] ... 3839445c 7838305c 78393148 5c784134 4f5c7843 385c7843 31345c78 46414948 2472305c 75303031 32694c5c 7845385c 7846465c 76305c75 30303030 5c784233 5c784132 5c784644 d4b8315c 7839325c 75303031 335c7530 3030305c 75303030 305c7530 3030305c 75303030 3049454e 445c7841 4542605c 78383222 2c202233 30225d>
It say's that it's saving the image in Core Data. However, what I'm getting are transparent squares and not photos.
And, every so often, when it's trying to get a slice from AWS, I get the following log error ... which also means nothing to me!
WARN: No such file or directory # rb_sysopen - https://XXXXXXXXXX.s3-ap-southeast-1.amazonaws.com/uploads/photo/photoImage20/77/photoImage20.jpg ... [lots more]
When I place the complete URL pointing to Amazon into Safari, it shows the photo perfectly. Sigh.
Any help would be gratefully received as, once again, I'm stumped.
There was an exercise in futility.
24 hours to discover it was a comma in the wrong place.
#sysMessage.messagePictureData = Base64.strict_encode64(open(imagestring).read),
#sysMessage.messagePuzzleNumber = "#{sendPiece}"
Two things concatenated and hours lost.
Thanks to those who read this.