Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: What do you think of my CropImage class Date: Thu, 21 Jul 2016 11:58:31 +0200 Organization: Decebal Computing Lines: 112 Message-ID: <8737n36ucx.fsf@Equus.decebal.nl> References: <87twfk93vu.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="1944"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rnMUEUiCFmeoAWX1nQTDcCvBzrf8bkDU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:ECo4fYul/e/CggThOLaIaKZGcSI= sha1:ZRPCNiSorv3kVp3ZaM22JiPcg+0= Xref: csiph.com comp.lang.java.programmer:35042 --=-=-= Content-Type: text/plain Content-Disposition: inline I was not completely clear :'-( so here some more info. I have no real experience with Swing and had an itch to scratch. That is why I wrote this program: to get some experience with Swing and get a little tool to make my live a little easier. At the moment it is the first try: there is a lot that could be done much better, but at least this makes live a little easier for me. The problem is that I like to crop part of a photo to post on Instagram. For example: https://www.instagram.com/p/BIGN8pjACDT/ and: https://www.instagram.com/p/BIGNtrpAmnT/ The first is not perfect, because the leg of the frog is cut of, but I want to have a one on one crop to keep the quality of the picture. (Or a 2, 3, 4 on 1 crop, but that is for a next step.) To show what I mean see the picture in the link. Sometimes a picture says more as a thousand words. ;-) https://drive.google.com/file/d/0BzW5q7uL-6z0XzNJb0FSRFFxMDA/ Gimp does not work (at least for me), because I have to crop exactly a piece of 1080x1080. I do not know how to do this with Gimp. Also when it is not correct I need to draw again, with the program I have just to move the cursor a little and click again. Would be better when I could drag the square, but again: this is just my first try. A rundown of what the program does: When it starts it asks for a graphic file to be displayed. It displays this with both the width and height divided by eight because I want to see the complete picture. The program displays a square of 135x135 in the upper left corner. When multiplied by 8 this gives the wanted 1080x1080. By clicking in the picture the square is moved to select the part of the picture I want to crop. By clicking on crop a file is selected to save the selected area and the saved part is displayed. The displaying of the selected part is done without re-sizing because I want to see exactly what I did select and it can almost be displayed on my screens. If I am satisfied with the cropped image I can click load to start with the next picture. What needs to be improved: - It should be system independent. For me pack did not work, so I put things on a hard coded position. This will probably be no problem when it is run on another Linux machine, but could wreck havoc on a Windows machine. - I should know if the image is rotated, so I could rotate the cropped image also. Maybe this is not really important, because I am thinking about putting all pictures in a SQLite database and then the rotation will also be stored. - After loading an image the first click results in flicker. This should be solved. - I want to have the possibility to add comment to the picture. (EXIF) - It now only works with the primary dimensions of Instagram, but it should also work with the other two. After this it should also work with the dimensions of the other Social Media and it should be possible to add your own custom dimensions. (SQLite to the rescue.) - Possibility to resize. (Select an area of 2.160x2.160 and crop it to 1.080x1.080). - Instead of clicking it should work with dragging the square (or rectangle). - Probably a lot of other things. :-D I am open to suggestions. On Wednesday 20 Jul 2016 09:15 CEST, Cecil Westerhof wrote: > I need to crop some images and decide to write a Java program for > it. At the moment it is very rudimentary, I plan to add some > functionalities and because I have very little experience with GUI > comments on how to implement the GUI better are welcome. > > > At the moment it is build with my camera's in mind and cropping for > InstaGram, but when it is seen as useful I will make it more > generic. > > > I have a few problems, the most important are: - After loading the > first or a new image the first click makes the image disappear and > painted again. Subsequent clicks do not have this problem. - The > original photo can be rotated. How can I find this out and make the > cropped image also rotated? - How can I add comment to an image? - > After saving the cropped image I want to display it also. What would > be the best way to do this? > > Some of the functionalities I want to add (other ideas are welcome): > - Working with different sets of cropping. - Possibility to resize. > (Select an area of 2.160x2.160 and crop it to 1.080x1.080). - > Working with a database. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof --=-=-=--