Congratulations to Cicadaman & co. for getting Froyo running on the Nook Color! Visit the nook Color portal!
See Rooting new hardware FIRST if you have a nook original with a 1003* serial# or above.

Apps

From nookDevs

Jump to: navigation, search

Contents

Installing apps

With FileManager

Apps can be installed with an Android launcher and the FileManager included in modified 1.4.

  1. With a computer copy the android .apk to the nook (the internal memory or extra MicroSD)
  2. Open the FileManager, and navigate to the folder where the .apk file is stored.
  3. Select the .apk file, then touch the green Android icon. It'll prompt you to install.

See your launcher's page for adding installed applications to it's home page.

With adb

The following are examples of installing apps with adb from the Android SDK .

Browser

  1. Download https://nookdevs.com/Browser.apk
  2. adb install Browser.apk
  3. adb shell am start 'https://nookdevs.com' where https://nookdevs.com is your webaddress to load
  4. Control it with the touchscreen if the page is long enough or with the VNC otherwise

Pandora

I'm sure people will be asking so here is the pandora.apk

  1. Download the app you want. Google for it, we aren't gonna tell you where they are
  2. In terminal run this command: adb install APP.apk. It will show some output and hopefully tell you its done!
  3. Run adb shell
  4. Using the pandora app as a example you would run: am start -n com.pandora.android/.Main

You can find the com.pandora.android part of the URL by doing pm list packages in adb shell

Busybox

The busybox binary is available here, courtesy of and with instructions from http://benno.id.au/

       adb push busybox /data/local 
       adb shell chmod 755 /data/local/busybox 
       adb shell mkdir /data/busybox 
       adb shell /data/local/busybox --install 

You can now play with everything that busybox has to offer, for expample you can kill the browser with

       adb shell /data/local/busybox killall com.android.browser

Running Apps

Android apps can also be run with an Android launcher or adb. Custom apps can't be run with the Barnes and Noble launcher.

If you are using adb, you will need to fix WiFi drops to run most of the apps.

With adb before installing/running the apps you will need to connect to your nook thru adb.

Using VNC to control input

See VNC


Push content Wireless with bash code

Not sure if this is useful... but I like to push content on to my nook from the PC without bothering with usb cords. I have created some bash code for the personal computer that will do this. Simply copy and paste it into a file. Name it and give the correct permissions and away you go. There is some configurations but that is all explained. Simply call the script and specify the files on the argument list, and all should be pushed onto the nook.


The script has the following requirements on the PC/Network

1) The PC has the android SDK installed

2) The PC must have a BASH shell running (linux, Mac, and Windows with cygwin)

3) The PC and Nook are in the same network subnet (ie same Local Area Network), not sure if adb works over NAT (routers) never really tried but I don't recommend it. I doubt the android sdk was meant for remote development.


The script has requirements on the Nook

1) Nook is turned on

2) Nook is connected to the wireless router

3) Nook has adb up and running (its been rooted)


Example of typical usage:

user:~>  file_1 file_2 /path/to/file_3
connected to 192.168.0.102:5555
375 KB/s (62242 bytes in 0.161s)
475 KB/s (42242 bytes in 0.061s)
275 KB/s (82242 bytes in 0.261s)
user:~>


Configuration notes

1) I assume you have all hacked your nook and have adb installed on your personal computer. You will need to specify the path to that in the script (see comments in the script on where to do that)

2) Make sure you edit in the IP address of your nook. Unless you like editing text files, it is a good idea to assign the nook a static IP in the DHCP server. This way the nook will always have the same IP and this script will always work.


The script:

#! /bin/bash

# Add the path to the adb tool in the quotations
ADB="/path/to/adb"

# this is where the content is placed, it is the equivalent of the my documents folder
# the expansion card is simply "/sdcard/"
NOOK_HOME="/system/media/sdcard/my documents/"

# INSERT NOOK IP in the quotations below
# Assigning nook a static IP on the DHCP table is needed
# to avoid constant updating of this file every time the IP changes
NOOK_IP="IP ADDRESS ie 192.168.0.100"

# Try to connect to the device
$ADB connect $NOOK_IP

# tests to see if we are connected
if [ "$?" -ne "0" ] ; then
        exit ;
fi

# Adds each file specified on the command line
for i in "$@" ; do
        # Note that the path name is stripped from the arguments, 
        # so any sub folders will not be copied, it will all be placed at top level
        $ADB push $i "$NOOK_HOME${i##*/}" ;
done

# disconnect from the device
$ADB disconnect


Some notes:

The script doesn't always work first time. It is usually problems with connecting to the device. Just try it multiple times. Ocasionally starting and stopping adb on the nook was required. Then in extreme events it requires reseting the nook wireless connection by forcing a reconnect on the nook and/or restarting the router itself.

The script is meant for any POSIX environment (ie Linux, MAC, etc.). Windows users you will have to run cygwin or something similar to use this script. Sorry, but I am a Linux man.



that's not really useful to me personally, but to add to requirements - adb needs to be running over wifi. As of late 2.4.x softroot that's disabled by default. There's samba server ported to android (i dont have url but it comes up on top in google). I think it would be more beneficial to get that running on nook. I would move it to your Talk page. --Spec 08:23, 6 December 2010 (PST)

Automatically convert scanned images into a Nook Optimized PDF

This is an application created by pilotmm. Apologies, but didn't go through the trouble of uploading the source onto a repository. Truth is I do not know how to use repositories or creating application pages. However I figured it would be better to share a useful application in a messy way than to keep it all to myself.

This is a program for those that want to digitize their books and print-outs for reading on the nook. After scanning and possibly some cropping you should have a bunch of images like 1.jpg, 2.jpg etc. When one executes this program inside the directory, it will seek out all the images with the names 1.jpg 2.jpg etc. to create the document. The pdf document is optimized for Nook viewing, this means that the pdf pages are sized to the recommended dimensions for pdf viewing on the nook, furthermore the images are scaled to the resolution of the nook screen, finally there are no margins. This means that the document will use maximum space on the nook screen, and be displayed with minimal distortion.

The program has a couple requirements. These requirements are not needed at compile time, thus one can compile then pass the --help argument to learn how to use it and the requirements.

Installation calls for copying the following source code and compiling. There are three files, the first is "jpg2nook.cpp" and the source code is:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

// geometric constants
const double pageW=3.54;
const double pageH=4.80;
const unsigned long imageW=600;
const unsigned long imageH=800;

// file name constants
const char* latexBase="jpg2nook_latex";
const char* latexFile="jpg2nook_latex.tex";
const char* latexPdf="jpg2nook_latex.pdf";
const char* deleteFilter="jpg2nook_";
const char* defExtension=".pdf";

class command;
class imageFile;

// algorithm variables
const char* title="Untitled";
const char* author="Unknown";
const char* name="untitled.pdf";
double width=pageW;
double height=pageH;
unsigned long iW=imageW;
unsigned long iH=imageH;
bool keepAspect=true;
list preComms;
list postComms;
list imageList;

#include "jpg2nook_helper.h"

int main(int argc,char** argv)
{
        int retVal=0;
        fstream latexOut;

        try
        {
                // process the arguments
                if(!processArgs(argc,argv))
                        throw 1;
        
                // open/create the latex source file
                latexOut.open(latexFile,fstream::out);
                if(!latexOut.is_open())
                {
                        cout << "Failed to open " << latexFile << endl;
                        throw 1;
                }
        
                // Print the tex header
                printHeader(latexOut,width,height,title,author);

                // Load in all the images
                getImages();
        
                // Loop through for each image name
                for(list::iterator it=imageList.begin();it!=imageList.end();it++)
                {
                        // create a temporary copy
                        cp((*it).original(),(*it).custom());
                        // apply pre-processing commands
                        for(list::iterator itComm=preComms.begin();itComm!=preComms.end();itComm++)
                        {
                                (*itComm).exec((*it).custom());
                        }
                        // resize
                        resize((*it).custom(),iW,iH);
                        // apply post-processing commands
                        for(list::iterator itComm=postComms.begin();itComm!=postComms.end();itComm++)
                        {
                                (*itComm).exec((*it).custom());
                        }
                        // convert to pdf
                        convert((*it).custom(),(*it).pdf());
                        // print the image into tex document
                        printImage(latexOut,(*it).pdf());
                }
        
                // write the tex footer
                printFooter(latexOut);
        
                // compile the pdf
                pdflatex(latexBase,6);

                // move the pdf to the correct places
                char lastName[256];
                mv(latexPdf,appendExtension(name,defExtension,lastName));
        }
        catch(int e)
        {
                retVal=e;
                cout << "An error has occured, exiting" << endl;
        }

        // delete all the extra files that were created
        clean();
        latexOut.close();
        latexOut.clear();

        return 0;
}

The next is "jpg2nook_helper.h" the source is given below:


// for writing the latex file
void printHeader(ostream &out,double page_width,double page_height,const char* doc_title,const char* doc_author);
void printImage(ostream &out, const char* imageName);
void printFooter(ostream &out);

// for the processing commands
class command
{
        private:
                list wordList;

        public:
                command();
                command(const command& asg);
                command(int argc,const char** argv,int &atArg);

                command& operator=(const command& asg);

                void load(int argc,const char** argv,int &atArg);
                int exec(const char* fn) const ;
};

// Misc help functions
bool isStringSame(const char* strA,const char* strB);
template void switchVariable(T &A,T &B);
void cp(const char* from,const char* to);
void mv(const char* from,const char* to);
void rm(const char* file);
void convert(const char* from,const char* to);
void pdflatex(const char* file,unsigned long n=1);
bool isArtifact(const char* fn);
const char* appendExtension(const char* name,const char* ext,char* buffer);

bool processArgs(int argc,char** argv);

class imageFile
{
        private:
                static unsigned long iNum;

                char origName[256];
                char custName[256];
                char pdfName[256];
                char baseName[256];

                void set(unsigned long num);

        public:
                imageFile();
                imageFile(unsigned long i);
                imageFile(const imageFile &asg);

                imageFile& operator=(const imageFile &asg);

                const char* original() const ;
                const char* custom() const ;
                const char* pdf() const ;
                const char* base() const ;
};

void readDirectory(list &files);
void getImages();

void resize(const char* fn,unsigned long imW, unsigned long imH);

void clean();

#include "jpg2nook_helper.cpp"

Finally the last source file is "jpg2nook_helper.cpp"


void printHeader(ostream &out,double page_width,double page_height,const char* doc_title,const char* doc_author)
{
        out << "" << endl;
        out << "\\documentclass[10pt]{article}" << endl;
        out << "\\pagestyle{empty}" << endl;
        out << "\\usepackage{graphicx}" << endl;
        out << "\\usepackage{amsmath}" << endl;
        out << "\\usepackage{amssymb}" << endl;
        out << "\\usepackage{subfig}" << endl;
        out << "\\usepackage{rotating}" << endl;
        out << "\\usepackage{listings}" << endl;
        out << "\t\\lstset{language=C++,numbers=left,frame=single,xleftmargin=1cm,breaklines=true,basicstyle=\\scriptsize}" << endl;
        out << "% \\usepackage{amsthm}" << endl;
        out << "\\usepackage{array}" << endl;
        out << "\t\\setlength{\\extrarowheight}{0.2cm}" << endl;
        out << "\\usepackage{xy}" << endl;
        out << "\\usepackage{natbib}" << endl;
        out << "\\bibliographystyle{asmems4}" << endl;
        out << "\\usepackage[top=-1in,bottom=0in,left=-1in,right=0in,paperwidth=" << page_width << "in,paperheight=" << page_height << "in]{geometry}" << endl;
        out << "" << endl;
        out << "" << endl;
        out << "\\DeclareMathAlphabet{\\mathpzc}{OT1}{pzc}{m}{it}" << endl;
        out << "" << endl;
        out << "\\pdfpagewidth " << page_width << "in" << endl;
        out << "\\pdfpageheight " << page_height << "in" << endl;
        out << "\\headheight 0.0in" << endl;
        out << "\\headsep 0in" << endl;
        out << "\\textwidth " << page_width << "in" << endl;
        out << "\\textheight " << page_height << "in" << endl;
        out << "\\topmargin -1.0in" << endl;
        out << "\\oddsidemargin -1.0in" << endl;
        out << "\\evensidemargin 0in" << endl;
        out << "" << endl;
        out << "% Title Page" << endl;
        out << "\\title{" << doc_title << "}" << endl;
        out << "" << endl;
        out << "\\author{" << doc_author << "}" << endl;
        out << "" << endl;
        out << "\\clubpenalty=100000" << endl;
        out << "\\widowpenalty=100000" << endl;
        out << "" << endl;
        out << "\\begin{document}" << endl;
        out << "" << endl;
        out << "\\maketitle" << endl;
        out << "" << endl;
}

void printImage(ostream &out, const char* imageName)
{
        out << "" << endl;
        out << "\\begin{figure}[htbp]" << endl;
        out << "\\includegraphics[width=\\textwidth,height=\\textheight,keepaspectratio]{" << imageName << "}" << endl;
        out << "\\end{figure}" << endl;
        out << "" << endl;
        out << "\\clearpage" << endl;
        out << "" << endl;
}

void printFooter(ostream &out)
{
        out << "" << endl;
        out << "\\end{document}" << endl;
        out << "" << endl;
}

command::command() : wordList(list())
{}

command::command(const command& asg) : wordList(asg.wordList)
{}

command::command(int argc,const char** argv,int &atArg) : wordList(list())
{
        this->load(argc,argv,atArg);
}

command& command::operator=(const command& asg)
{
        this->wordList=asg.wordList;
        return *this;
}

void command::load(int argc,const char** argv,int &atArg)
{
        bool loop=true;
        while(loop)
        {
                if(atArg>=argc || atArg<0)
                {
                        cout << "Unexpectedly beyonde the range of arguments in loading command, give a '\\;' at the end of the list" << endl;
                        throw 1;
                }
                if((argv[atArg])[0]==';')
                        loop=false;
                else
                        wordList.push_back(argv[atArg]);
                atArg++;
        }
}

int command::exec(const char* fn) const
{
        char comStr[2048];
        unsigned int at=0;

        for(list::const_iterator it=wordList.begin();it!=wordList.end();it++)
        {
                if((*it)[0]=='{' && (*it)[1]=='}' && (*it)[2]==0)
                {
                        unsigned long atChar=0;
                        while(fn[atChar]!=0)
                                comStr[at++]=fn[atChar++];
                }
                else
                {
                        unsigned long atChar=0;
                        while((*it)[atChar]!=0)
                                comStr[at++]=(*it)[atChar++];
                }
                comStr[at++]=' ';
        }
        comStr[at++]=0;

        return system(comStr);
}

bool isStringSame(const char* strA,const char* strB)
{
        unsigned long i=0;
        while(strA[i]!=0 && strB[i]!=0)
        {
                if(strA[i]!=strB[i])
                        return false;
                i++;
        }
        return (strA[i]==strB[i]);
}

template
void switchVariable(T &A,T &B)
{
        T tmp;
        tmp=A;
        A=B;
        B=tmp;
}

void cp(const char* from,const char* to)
{
        unsigned long atComm=0;
        unsigned long at;
        char commStr[2048];

        commStr[atComm++]='c';
        commStr[atComm++]='p';
        commStr[atComm++]=' ';

        at=0;
        while(from[at]!=0)
                commStr[atComm++]=from[at++];

        commStr[atComm++]=' ';

        at=0;
        while(to[at]!=0)
                commStr[atComm++]=to[at++];

        commStr[atComm]=0;

        system(commStr);
}

void mv(const char* from,const char* to)
{
        unsigned long atComm=0;
        unsigned long at;
        char commStr[2048];

        commStr[atComm++]='m';
        commStr[atComm++]='v';
        commStr[atComm++]=' ';

        at=0;
        while(from[at]!=0)
                commStr[atComm++]=from[at++];

        commStr[atComm++]=' ';

        at=0;
        while(to[at]!=0)
                commStr[atComm++]=to[at++];

        commStr[atComm]=0;

        system(commStr);
}

void rm(const char* file)
{
        unsigned long atComm=0;
        unsigned long at;
        char commStr[2048];

        commStr[atComm++]='r';
        commStr[atComm++]='m';
        commStr[atComm++]=' ';

        at=0;
        while(file[at]!=0)
                commStr[atComm++]=file[at++];

        commStr[atComm]=0;

        system(commStr);
}

void convert(const char* from,const char* to)
{
        unsigned long atComm=0;
        unsigned long at;
        char commStr[2048];

        commStr[atComm++]='c';
        commStr[atComm++]='o';
        commStr[atComm++]='n';
        commStr[atComm++]='v';
        commStr[atComm++]='e';
        commStr[atComm++]='r';
        commStr[atComm++]='t';
        commStr[atComm++]=' ';

        at=0;
        while(from[at]!=0)
                commStr[atComm++]=from[at++];

        commStr[atComm++]=' ';

        at=0;
        while(to[at]!=0)
                commStr[atComm++]=to[at++];

        commStr[atComm]=0;

        system(commStr);
}

void pdflatex(const char* file,unsigned long n)
{
        unsigned long atComm=0;
        unsigned long at;
        char commStr[2048];

//      commStr[atComm++]='o';
//      commStr[atComm++]='p';
//      commStr[atComm++]='e';
//      commStr[atComm++]='n';
//      commStr[atComm++]='o';
//      commStr[atComm++]='u';
//      commStr[atComm++]='t';
//      commStr[atComm++]='_';
//      commStr[atComm++]='a';
//      commStr[atComm++]='n';
//      commStr[atComm++]='y';
//      commStr[atComm++]='=';
//      commStr[atComm++]='a';
//      commStr[atComm++]=' ';
        commStr[atComm++]='p';
        commStr[atComm++]='d';
        commStr[atComm++]='f';
        commStr[atComm++]='l';
        commStr[atComm++]='a';
        commStr[atComm++]='t';
        commStr[atComm++]='e';
        commStr[atComm++]='x';
        commStr[atComm++]=' ';

        at=0;
        while(file[at]!=0)
                commStr[atComm++]=file[at++];

        commStr[atComm]=0;

        for(unsigned long i=0;i=argc)
                                break;
                }
                // -S nookSideways
                if(isStringSame(argv[atArg],"-S"))
                {
                        atArg++;
                        double scl=height/width;
                        width=scl*width;
                        height=scl*height;
                        iW=scl*iW;
                        iH=scl*iH;
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -2 double size
                if(isStringSame(argv[atArg],"-2"))
                {
                        atArg++;
                        double scl=2;
                        width=scl*width;
                        height=scl*height;
                        iW=scl*iW;
                        iH=scl*iH;
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -pre preprocessor command
                if(isStringSame(argv[atArg],"-pre"))
                {
                        atArg++;
                        preComms.push_back(command(argc,const_cast(argv),atArg));
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -post postprocessor command
                if(isStringSame(argv[atArg],"-post"))
                {
                        atArg++;
                        postComms.push_back(command(argc,const_cast(argv),atArg));
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -W doc width
                if(isStringSame(argv[atArg],"-W"))
                {
                        atArg++;
                        double wArg=atof(argv[atArg++]);
                        double scl=wArg/width;
                        width=scl*width;
                        iW=scl*iW;
                        if(keepAspect)
                        {
                                height=scl*height;
                                iH=scl*iH;
                                keepAspect=false;
                        }
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -H doc height
                if(isStringSame(argv[atArg],"-H"))
                {
                        atArg++;
                        double hArg=atof(argv[atArg++]);
                        double scl=hArg/height;
                        height=scl*height;
                        iH=scl*iH;
                        if(keepAspect)
                        {
                                width=scl*width;
                                iW=scl*iW;
                                keepAspect=false;
                        }
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -T title
                if(isStringSame(argv[atArg],"-T"))
                {
                        atArg++;
                        title=argv[atArg++];
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -A author
                if(isStringSame(argv[atArg],"-A"))
                {
                        atArg++;
                        author=argv[atArg++];
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -n name
                if(isStringSame(argv[atArg],"-n"))
                {
                        atArg++;
                        name=argv[atArg++];
                        valid=true;
                        if(atArg>=argc)
                                break;
                }
                // -h or --help
                if(isStringSame(argv[atArg],"-h") || isStringSame(argv[atArg],"--help"))
                {
                        atArg++;
                        cout << "This program creates pdf document for reading on the NOOK e-reader. The program assumes that each page" << endl;
                        cout << "will be given as an image. The assumed image names are '1.jpg' for the first page, '2.jpg' for the" << endl;
                        cout << "second, 'n.jpg' for every other subsequent page." << endl;
                        cout << "" << endl;
                        cout << "This program relies on the imagemagic 'convert' and 'mogrify' commands." << endl;
                        cout << "See 'www.imagemagick.org' to install." << endl;
                        cout << "" << endl;
                        cout << "This program also relies on the 'pdflatex' command to convert the document into a pdf." << endl;
                        cout << "See 'www.tug.org/applications/pdftex/' for more information" << endl;
                        cout << "" << endl;
                        cout << "This program also relies on the 'rm', 'mv' and 'cp' commands to process various files." << endl;
                        cout << "These are standard commands on any POSIX complient system, see administrator if they are not there" << endl;
                        cout << "" << endl;
                        cout << "-L                              Create in landscape." << endl;
                        cout << "-S                              Create to read with nook sideways (scales all by l/w)." << endl;
                        cout << "-2                              Doubles size." << endl;
                        cout << "-pre preprocessor_command       Apply an image processing command before resize." << endl;
                        cout << "                                All arguments up to '\\;' are interpreted as a command and arguments." << endl;
                        cout << "                                The end argument '\\;' must be given to signify the end of the command." << endl;
                        cout << "                                The argument '{}' is reserved as a placeholder for the image name." << endl;
                        cout << "-post postprocessor_command     apply an image processing command after resize." << endl;
                        cout << "                                All arguments up to '\\;' are interpreted as a command and arguments." << endl;
                        cout << "                                The end argument '\\;' must be given to signify the end of the command." << endl;
                        cout << "                                The argument '{}' is reserved as a placeholder for the image name." << endl;
                        cout << "-W document_width               Specify a custom document width in inches. If only -W is given then" << endl;
                        cout << "                                then the aspect ratio is preserved" << endl;
                        cout << "-H document height              Specify a custom document height in inches. If only -H is given then" << endl;
                        cout << "                                then the aspect ratio is preserved" << endl;
                        cout << "-T title                        Give a title for the pdf document" << endl;
                        cout << "-A author                       Give and author for the pdf document" << endl;
                        cout << "-n name                         Give a name for the final pdf." << endl;
                        cout << "                                The '.pdf' extension automatically appended if not given." << endl;
                        cout << "-h or --help                    Shows a list of options" << endl;
                        return false;
                }
                if(!valid)
                {
                        cout << argv[atArg] << " is not recognized as an option. Use '-h' or '--help' to see a list of options" << endl;
                        return false;
                }
        }
        return true;
}

void imageFile::set(unsigned long num)
{
        stringstream ss;
        ss << num;
        const char* numStr=ss.str().c_str();

        unsigned long at=0;
        while(numStr[at]!=0 && at<255)
        {
                origName[at]=numStr[at];
                at++;
        }
        if(at==255)
        {
                cout << "File name too long" << endl;
                throw 1;
        }
        origName[at++]='.';
        origName[at++]='j';
        origName[at++]='p';
        origName[at++]='g';
        origName[at]=0;

        at=0;
        while(deleteFilter[at]!=0 && at<255)
        {
                custName[at]=deleteFilter[at];
                pdfName[at]=deleteFilter[at];
                baseName[at]=deleteFilter[at];
                at++;
        }
        if(at==255)
        {
                cout << "File name too long" << endl;
                throw 1;
        }

        unsigned long atNum=0;
        while(numStr[atNum]!=0 && at<255)
        {
                custName[at]=numStr[atNum];
                pdfName[at]=numStr[atNum];
                baseName[at]=numStr[atNum];
                atNum++;
                at++;
        }
        if(at==251)
        {
                cout << "File name too long" << endl;
                throw 1;
        }

        unsigned long atNow=at;

        at=atNow;
        custName[at++]='.';
        custName[at++]='j';
        custName[at++]='p';
        custName[at++]='g';
        custName[at]=0;

        at=atNow;
        pdfName[at++]='.';
        pdfName[at++]='p';
        pdfName[at++]='d';
        pdfName[at++]='f';
        pdfName[at]=0;

        at=atNow;
        baseName[at]=0;

        return;
}

imageFile::imageFile()
{
        this->set(iNum++);
}

imageFile::imageFile(unsigned long i)
{
        this->set(i);
}

imageFile::imageFile(const imageFile &asg)
{
        *this=asg;
}

imageFile& imageFile::operator=(const imageFile &asg)
{
        strcpy(this->origName,asg.origName);
        strcpy(this->custName,asg.custName);
        strcpy(this->pdfName,asg.pdfName);
        strcpy(this->baseName,asg.baseName);
        return *this;
}

const char* imageFile::original() const
{
        return origName;
}

const char* imageFile::custom() const
{
        return custName;
}

const char* imageFile::pdf() const
{
        return pdfName;
}

const char* imageFile::base() const
{
        return baseName;
}

unsigned long imageFile::iNum=1;

unsigned long readDirectory(list &files)
{
        // Read the current directory contents
        unsigned long cnt=0;
        DIR *dp;
        struct dirent *ep;
        dp = opendir("./");
        if(dp==NULL)
        {
                cout << "Failed to open local directory" << endl;
                return 1;
        }

        while((ep=readdir(dp))!=NULL)
        {
                string file=ep->d_name;
                files.push_back(file);
                cnt++;
        }
        closedir(dp);

        return cnt;
}

void getImages()
{
        list files;

        readDirectory(files);

        bool fnd=true;
        unsigned long atImage=1;
        while(fnd)
        {
                fnd=false;
                for(list::iterator it=files.begin();it!=files.end();it++)
                {
                        imageFile next=imageFile(atImage);
                        if(isStringSame(next.original(),(*it).c_str()))
                        {
                                imageList.push_back(next);
                                fnd=true;
                                break;
                        }
                }
                atImage++;
        }
}

void resize(const char* fn,unsigned long imW, unsigned long imH)
{
        stringstream ss;
        ss << "mogrify -resize " << imW << 'x' << imH << "\\> " << fn;
        system(ss.str().c_str());
}

void clean()
{
        list files;

        readDirectory(files);

        for(list::iterator it=files.begin();it!=files.end();it++)
        {
                if(isArtifact((*it).c_str()))
                        rm((*it).c_str());
        }
}

Installation requires one to copy and past the above text into the files and give those files the same names as explained above. Then one can compile is by executing the command:

g++ jpg2nook.cpp -o jpg2nook

Then one can move the new executable "jpg2nook" to the ~/bin/ directory to make it available in all directories.

The options and requirements as given by --help option:


This program creates pdf document for reading on the NOOK e-reader. The program assumes that each page
will be given as an image. The assumed image names are '1.jpg' for the first page, '2.jpg' for the
second, 'n.jpg' for every other subsequent page.

This program relies on the imagemagic 'convert' and 'mogrify' commands.
See 'www.imagemagick.org' to install.

This program also relies on the 'pdflatex' command to convert the document into a pdf.
See 'www.tug.org/applications/pdftex/' for more information

This program also relies on the 'rm', 'mv' and 'cp' commands to process various files.
These are standard commands on any POSIX complient system, see administrator if they are not there

-L                              Create in landscape.
-S                              Create to read with nook sideways (scales all by h/w).
-2                              Doubles size.
-pre preprocessor_command       Apply an image processing command before resize.
                                All arguments up to '\;' are interpreted as a command and arguments.
                                The end argument '\;' must be given to signify the end of the command.
                                The argument '{}' is reserved as a placeholder for the image name.
-post postprocessor_command     apply an image processing command after resize.
                                All arguments up to '\;' are interpreted as a command and arguments.
                                The end argument '\;' must be given to signify the end of the command.
                                The argument '{}' is reserved as a placeholder for the image name.
-W document_width               Specify a custom document width in inches. If only -W is given then
                                then the aspect ratio is preserved
-H document height              Specify a custom document height in inches. If only -H is given then
                                then the aspect ratio is preserved
-T title                        Give a title for the pdf document
-A author                       Give and author for the pdf document
-n name                         Give a name for the final pdf.
                                The '.pdf' extension automatically appended if not given.
-h or --help                    Shows a list of options

Finally, below is an example of typical usage. Note that the -pre argument is increasing the contrast of the scanned images.

jpg2nook -T "Optimum aerodynamic design using the Navier-Stokes equations" -A "A. Jameson, N. A. Pierce, L. Martinelli" -n "Optimum_aerodynamic_design_using_the_Navier_Stokes_equations"-pre mogrify -contrast-stretch 0%x100% {} \;

Hope you all enjoy....

Retrieved from "https://nookdevs.com/Apps"
Personal tools
  • Log in / create account
Navigation
nookDevs Team
miscellaneous