WesleyyC / Image-Editor

A command line image editor written in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save without path

WesleyyC opened this issue · comments

Default: Save the file in the same directory as the loaded filed but change the name a little bit.
Optional: Customize path but white space should be taken care of.

The white space in folder name is originally not able to take because the console only read one token instead of the whole line. (Same problem might goes to the input file too.) After changing to readLine(), white space can be taken care of. An example path can be "/Users/wesley/Desktop/test good/test1234.jpg", where the white space should be space as it is taken as a String and it should be followed by the save file name.

After thinking about the path issue, it would be great if we can parse the escape sequence"\ " to " ". There is a function in the scanner console that can configure the scanner to ignore "". It is delimiter or something.

I accidentally remove your comment, but yes, that's what I am referring to. Because when the user put in the path as unix path, they will use escape sequence for white space in the path. However, Java does not like that and she does not understand the white space escape sequence. Therefore, when user type path in unix, like "Whietspace\ Test\ Folder", we want to take the string as "Whitespace Test Folder".

Also, in the load image function, the read() only works for path with no white space while the readLine() does not work at all, try to debug, but really don't know why.

Alright cool. I see what you mean. I will take care of that.

Just found something related to file path reading. Line 166
String tmp = console.next().toLowerCase();
Why do we need to convert the file path to lowercase? Can't a file path be upper case?

I am just testing stuff, and toLowerCase might not help. You can clean it up. Same goes to save image. :)

Well.. the white space discussion should not take place in here... Opening new issue #4

This interaction comes up and i think there should be a better way to do it:

Enter command:
save
Would you like to save under the same directory as the source image? y/n
/Users/wesley/Desktop/edited2.jpg
Sorry, we do not understand your input. Aborting save.
Image saving failed.

Maybe can ask the user to hit enter if use the default directory, or they can specify the directory, and if the system through a exception, catch it by asking the user type the directory again. :)

Well, my original design was like this... The user will need to answer yes or no to indicate whether they would like to save under the same folder. But if you want to change that, I can do that too:)

ticket 1

Yeah, I saw what you are trying to do. But think ask y/n is more like an extra step.

I think what we can do is ask the user for a directory, and if s/he does not put in directory, use the default.

screen shot 2014-11-02 at 4 42 52 pm
Changed.

@WesleyyC One more thing about saving images: in TheImage.java line 115

ImageIO.write(im, "jpg", saveImg);

I am wondering why this is jpg in here but the saved image is actually in png format.
I just found out this is related to a new issue I raised: #9

@SerinaTan I see what you are saying and I will try to test that out.

@SerinaTan One more thing we can add is even though the user only gives us a path to a directory, not a file, we can still help them to save it.

Haha, well... I guess we can do that. But I am still trying to figure out how we can do this more elegantly. I am now spending way too much time trying to write good-looking code :D

I thought about it. In my opinion, it makes more sense to pick either way: file path or directory path. It gets muddy if the user can type "anything" they want. I think asking the user for a directory path only is a good idea. We can also rename the image based on the operations we did to the image. Referring => #11