I've been struggling with this for the last few hours and can't seem to figure it out at all. To start I'll lay out what I'm trying to do.
I want to make it so that when you generate a craft idea on this page
http://craftspo.com/craft-idea-generator/
it saves an image of the idea on my server (so that I could then allow the user to pin it on Pinterest, share it on FB, and so on).
So far, I've managed to get it so that when they click the button, it uses html2canvas to snag a snapshot of the table. The problem is that image ends up being in base64, so it's pretty much unusable.
From what I've read, you can really only decode (and then save) base64 images to a server using PHP. And of course PHP is only called whenever you load the page but I'd rather not make them reload the page every time they generate a new idea. So is there anything else I can do? Even if it means doing something completely different. At this point, I just wanna make it happen so I can feel like I conquered the problem!
if I recall correctly base64 or image has no different,
just like the comment above
you could use it like :
<img src="data:image;base64,etc"/>
if you don't want the user to reload, you could use ajax to replace the src using javascript/jquery, you could just replace it with base64 image instead link to image.
if the image ain't that big, I myself would prefer to use base64,
you could also save the base64 string into database, if it could hold the length :D
and use it later on
Related
I am building a plugin that requires a user to click on a Long link in chat. Somethig like this:
http://www.example.com/sample.php?code=124ds8g89fgfg9fd9g76hg89f7d698d67fgh7
Whenever i send this to the user:
sender.sendMessage(url);
Only part of the link is copied...example: http://www.example.com/sample.php?code=124ds8
How do i make minecraft accept the full URL length? I do not want to use 3rd Part Url shorten-ers either. Thanks!
Minecraft will automatically wrap onto the next line, or cut of a part of the Link/Message if it is too long, it can only fit so many characters into the textbox.
Your best bet is to use something like goo.gl or bit.ly to shorten the links into something more manageable.
I know that Microsoft office uses different encoding, what happen is when someone copy and paste texts from office to java text panel, it looks OK. But you then store it into MySQL database, and retrieve it. It suddenly become all kind of rubbish Latin characters.
I've tried to convert it to utf-8 before store, but seems not work.
Wonder if there is anyway you can detect whether there is any latin characters in your text, so I can simply popup an alert to let user know before they save it.
Or, if there is anyway to disable the jTextField to only display everything in UTF-8 characters, so that when user copy and paste from word, it auto shows all the random codes instead of looking fine (at the beginning)
Example: With user entered something in word, and paste to jTextField, we pass the string directly(Note our sql database is utf8_general_ci), we then just fetch it to the JPanel, and we get:
ÃÃâ€
’¢â‚¬ââââ‚
I've had similar issues. First thing to do is find out what exactly has been written to the database. This is very easy with MySQL, just logon and run
SELECT HEX( column ) FROM table;
That'll give you the bytes that have been written to the table. You can then use an app I wrote for this very purpose. Take the hex string you got back from MySQL and give it to the main class using the -b flag for bytes. You'll get a whole heap of output, and hopefully one of them will be what you had originally.
Once you know what it's being stored as, you have a starting point for debugging.
I have an image file (for example img.png) which is updated (overwritten) every 20-30ms using a java program.
Now, I want the client to be able to 'watch' the image as it changing (it will look like a video streaming).
I used Javascript to update the image every 20-30ms but it is not that efficient as it consumes a lot of processing power. I also tried to use Ajax and jQuery.
Any suggestions on how to improve the performance? Can I use a player like jwPlayer or Flow Player? Should I use something different and more efficient?
Thanks.
PS. I have already implemented it using JApplet but I would like to avoid that solution.
You can update image by appending a random string at the end.
function update(){
$('#image').attr('src', $('#image').attr('src')+'?'+Math.random());
}
setTimeout("update()",150);
sounds like you just want a slideshow; there are super fast efficient slideshows in JavaScript, i'm lazy so here's the jQuery version:http://mathiasbynens.be/demo/slideshow if you're having performance issues using this, it's not because of the slideshow
You can update image using javascript timer (setTimeout) eg url
..it consumes a lot of processing power
Note that 'processing power' is not the same as 'bandwidth'.
To save bandwidth, it would make more sense to assemble the images into a video at the server side, and stream the video to the client. Video compression formats generally save a lot of bytes over a series of images, because they can compress images taking into account similar parts of different frames.
I want to get the list of all Image urls from HTML source of a webpage(Both abosulte and relative urls). I used Jsoup to parse the HTML but its not giving all images. For example when I am parsing google.com HTML source its showing zero images..In google.com HTML source image links are in form..
"background:url(/intl/en_com/images/srpr/logo1w.png)
And in rediff.com the images links are in form..
videoArr[j]=new Array("http://ishare.rediff.com/video/entertainment/bappi-da-the-first-indian-in-grammy-jury/2684982","http://datastore.rediff.com/h86-w116/thumb/5E5669666658606D6A6B6272/v3np2zgbla4vdccf.D.0.bappi.jpg","Bappi Da - the first Indian In Grammy jury","http://mypage.rediff.com/profile/getprofile/LehrenTV/12669275","LehrenTV","(2:33)");
j = 1
videoArr[j]=new Array("http://ishare.rediff.com/video/entertainment/bebo-shahid-jab-they-met-again-/2681664","http://datastore.rediff.com/h86-w116/thumb/5E5669666658606D6A6B6272/ra8p9eeig8zy5qvd.D.0.They-Met-Again.jpg","Bebo-Shahid : Jab they met again!","http://mypage.rediff.com/profile/getprofile/LehrenTV/12669275","LehrenTV","(2:17)");
All images are not with in "img" tags..I also want to extract images which are not even with in "img" tags as shown in above HTML source.
How can I do this..?Please help me on this..
Thanks
This is going to be a bit difficult, I think. You basically need a library that will download a web page, construct the page's DOM and execute any javascript that may alter the DOM. After all that is done you have to extract all the possible images from the DOM. Another possible option is to intercept all calls by library to download resources, examine the URL and if the URL is an image record that URL.
My suggestion would be to start by playing with HtmlUnit(http://htmlunit.sourceforge.net/gettingStarted.html.) It does a good job of building the DOM. I'm not sure what types of hooks it has, for intercepting the methods that download resources. Of course if it doesn't provide you with the hooks you can always use AspectJ or simply modify the HtmlUnit source code. Good luck, this sounds like a reasonably interesting problem. You should post your solution, when you figure it out.
If you just want every image referred to in the page, can't you just scan the HTML and any linked javascript or CSS with a simple regex? How likely is it you'd get [-:_./%a-zA-Z0-9]*(.jpg|.png|.gif) in the HTML/JS/CSS that's not an image? I'd guess not very likely. And you should be allowing for broken links anyway.
Karthik's suggestion would be more correct, but I imagine it's more important to you to just get absolutely everything and filter out uninteresting images.
I want to create a serve resampled (downsized) version of images using jsp. The original images are stored in the database as blobs. I want to to create a jsp that serves a downsampled image with decent quality (not pixelated) as per the passed image width/height (e.g. getimage.jsp?imageid=xxxx&maxside=200) . Can you point me to a opensource api or code that I can call from the jsp page?
Java already contains libraries for image manipulation. It should be easy to resize an image and output it from a JSP.
This servlet looks like it does a very similar thing to what you want your JSP to do.
Is there anything wrong with the built-in Image.getScaledInstance(w, h, hints)? (*)
Use hints=Image.SCALE_SMOOTH to get non-horrible thumbnailing. Then use an ImageIO to convert to the required format for output.
*: well yes, there is something wrong with it, it's a bit slow, but really with all the other web overhead to worry about that's not likely to be much of an issue. It's also not the best quality for when upscaling images, where a drawImage with BICUBIC renderinghint is more suitable. But you're talking about downscaling only at the moment.
Be sure to check the sizes passed in so that you can't DoS your servlet by passing in enormous sizes causing a memory-eatingly-huge image to be created.