Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix output filename tagging with "_embed.jpg" taking 1 char from original name #2

Open
pablojr opened this issue Jun 9, 2014 · 4 comments

Comments

@pablojr
Copy link

pablojr commented Jun 9, 2014

Right now if no output filename is provided, F5Android library defaults to replacing the original extension by "_embed.jpg" but while doing so, it also messes up last char of original name. Example:
IMG_0001.jpg becomes IMG_000_embed.jpg (last 1 is accidentally chopped)

Fix:
Please change line 60 of Embed.java into
String extension = this.file.getName().substring(this.file.getName().lastIndexOf(".") );

Thanks.

@harlo
Copy link
Owner

harlo commented Jun 11, 2014

Thanks for the fix-- much appreciated. Would you submit it as a patch?

@harlo
Copy link
Owner

harlo commented Jun 11, 2014

Also, in PixelKnot, we didn't want the secret file named "XXX_embed.jpg" because that's a glaring flag that you've got a secret message embedded in a jpeg! So, maybe your patch should address that: what do you think would be a better naming convention?

@pablojr
Copy link
Author

pablojr commented Jul 10, 2014

Since Github doesn't allow to attach a file to an issue here it is:

commit ba7a3da3c9eec5aa14de14d85a6168d2ff8151d1
Author: Pablo J. Rogina <[email protected]>
Date:   Thu Jul 10 19:25:09 2014 -0300

    Fixed output filename tagging with "_embed.jpg" removing last char from original name

diff --git a/src/info/guardianproject/f5android/Embed.java b/src/info/guardianproject/f5android/Embed.java
index b0b44ce..bb87518 100644
--- a/src/info/guardianproject/f5android/Embed.java
+++ b/src/info/guardianproject/f5android/Embed.java
@@ -57,7 +57,7 @@ public class Embed {
            root_dir.mkdir();

        if(outFileName == null) {
-           String extension = this.file.getName().substring(this.file.getName().lastIndexOf(".") - 1);
+           String extension = this.file.getName().substring(this.file.getName().lastIndexOf(".") );
            this.outFile = new File(root_dir, this.file.getName().replace(extension, "_embed.jpg"));
            this.outFileName = this.outFile.getAbsolutePath();
        } else {

@pablojr
Copy link
Author

pablojr commented Jul 11, 2014

And regarding the secret file name, while using the camera for the input, I would expect just one file named and located as per the device's camera system (i.e. IMG_0000001.jpg at /storage/sdcard0/DCIM) so it will be placed among any other image taken with the default camera application.
And for the case of an existing image, I would say to provide a checkbox so the file will be overwritten (yes, I know, the original will be gone once embedded) or to create a new file with the same name at the same location but with extension 'jpgs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants