CustomAndroidAPI  1.05
 All Classes Namespaces Functions Variables Pages
it.custom.printer.api.android.CustomPrinter Class Reference

Public Member Functions

void close () throws CustomException
 
int getCommPortType () throws CustomException
 
boolean isPrinterOnline () throws CustomException
 
int getPrinterId () throws CustomException
 
String getFirmwareVersion () throws CustomException
 
String getAPIVersion () throws CustomException
 
byte[] getPrinterFullStatusBuffer () throws CustomException
 
PrinterStatus getPrinterFullStatus () throws CustomException
 
String getPrinterName ()
 
String getPrinterInfo ()
 
int getPageWidth ()
 
int getResolution ()
 
long getReadTimeout () throws CustomException
 
void setReadTimeout (int msecs) throws CustomException
 
long getWriteTimeout () throws CustomException
 
void setWriteTimeout (int msecs) throws CustomException
 
void clearReadBuffer () throws CustomException
 
int[] readData () throws CustomException
 
void writeData (int[] data) throws CustomException
 
void writeData (int[] data, int offset, int nBytes) throws CustomException
 
void writeData (byte[] data) throws CustomException
 
void writeData (byte[] data, int offset, int nBytes) throws CustomException
 
void printText (String text, int pixel_la, int pixel_w, PrinterFont font) throws CustomException
 
void printTextLF (String text, int pixel_la, int pixel_w, PrinterFont font) throws CustomException
 
void printText (String text, PrinterFont font) throws CustomException
 
void printTextLF (String text, PrinterFont font) throws CustomException
 
void printText (String text) throws CustomException
 
void printTextLF (String text) throws CustomException
 
void printImage (Bitmap image, int left_align, int widthOption, int width) throws CustomException
 
void printImage (Bitmap image) throws CustomException
 
void PrintBarcode (String brcText, int brcType, int brcHriType, int brcJustification, int brcWidth, int brcHeight) throws CustomException
 
void PrintBarcode (byte[] brcData, int nBytes, int brcType, int brcHriType, int brcJustification, int brcWidth, int brcHeight) throws CustomException
 
void PrintBarcode2D (String brcText, int brcType, int brcJustification, int brcWidth) throws CustomException
 
void PrintBarcode2D (byte[] brcData, int nBytes, int brcType, int brcJustification, int brcWidth) throws CustomException
 
void feed (int nFeeds) throws CustomException
 
void cut (int cutType) throws CustomException
 
void eject (int ejectType) throws CustomException
 
void present (int presentMM) throws CustomException
 

Static Public Attributes

static final int COMMTYPE_BLUETOOTH = 0
 
static final int COMMTYPE_ETHERNET = 1
 
static final int COMMTYPE_USB = 2
 
static final int COMMTYPE_COM = 3
 
static final int IMAGE_SCALE_NONE = 0
 
static final int IMAGE_SCALE_TO_FIT = 1
 
static final int IMAGE_SCALE_TO_WIDTH = 2
 
static final int IMAGE_ALIGN_TO_LEFT = 0
 
static final int IMAGE_ALIGN_TO_CENTER = -1
 
static final int IMAGE_ALIGN_TO_RIGHT = -2
 
static final int CUT_TOTAL = 0
 
static final int CUT_PARTIAL = 1
 
static final int EJ_EJECT = 0
 
static final int EJ_RETRACT = 1
 
static final int BARCODE_TYPE_CODABAR = -1
 
static final int BARCODE_TYPE_UPCA = -2
 
static final int BARCODE_TYPE_UPCE = -3
 
static final int BARCODE_TYPE_EAN13 = -4
 
static final int BARCODE_TYPE_EAN8 = -5
 
static final int BARCODE_TYPE_CODE39 = -6
 
static final int BARCODE_TYPE_ITF = -7
 
static final int BARCODE_TYPE_CODE93 = -8
 
static final int BARCODE_TYPE_CODE128 = -9
 
static final int BARCODE_TYPE_CODE32 = -10
 
static final int BARCODE_TYPE_QRCODE = -101
 
static final int BARCODE_TYPE_PDF417 = -102
 
static final int BARCODE_TYPE_DATAMATRIX = -103
 
static final int BARCODE_TYPE_AZTEC = -104
 
static final int BARCODE_HRI_NONE = 0
 
static final int BARCODE_HRI_TOP = 1
 
static final int BARCODE_HRI_BOTTOM = 2
 
static final int BARCODE_HRI_TOPBOTTOM = 3
 
static final int BARCODE_ALIGN_TO_LEFT = 0
 
static final int BARCODE_ALIGN_TO_CENTER = -1
 
static final int BARCODE_ALIGN_TO_RIGHT = -2
 

Detailed Description

Class definition for CUSTOM printers. Defines functionality to print text/image, read/write data to printer, etc

Member Function Documentation

void it.custom.printer.api.android.CustomPrinter.clearReadBuffer ( ) throws CustomException
inline

Clears the Read Buffer

Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.close ( ) throws CustomException
inline

Disconnect the link and release attached resources

Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.cut ( int  cutType) throws CustomException
inline

Sends a Cut command to the printer

Parameters
cutTypecut type
  • CUT_TOTAL - Perform a Total Cut.
  • CUT_PARTIAL - Perform a Partial Cut.
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.eject ( int  ejectType) throws CustomException
inline

Sends a Eject command to the printer

Parameters
ejectTypeeject type
  • EJ_EJECT - Perform a Eject.
  • EJ_RECTRACT - Perform a Retract.
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.feed ( int  nFeeds) throws CustomException
inline

Sends Feeds to the printer

Parameters
nFeedsnumber of LF to send
Exceptions
CustomException
String it.custom.printer.api.android.CustomPrinter.getAPIVersion ( ) throws CustomException
inline

Current API version

Returns
current API version eg 1.00
Exceptions
CustomException
int it.custom.printer.api.android.CustomPrinter.getCommPortType ( ) throws CustomException
inline

Returns the communication port type

Returns
the communication port type
  • COMMTYPE_BLUETOOTH for Bluetooth.
  • COMMTYPE_ETHERNET for Ethernet.
  • COMMTYPE_USB for Usb.
Exceptions
CustomException
String it.custom.printer.api.android.CustomPrinter.getFirmwareVersion ( ) throws CustomException
inline

Sends a get Firmware version command to printer and process the response

Returns
String with 4 characters Firmware version installed on printer eg 1.08
Exceptions
CustomException
int it.custom.printer.api.android.CustomPrinter.getPageWidth ( )
inline

Returns paper width in pixels / dots

Returns
Paper width for printer in pixels / dots
PrinterStatus it.custom.printer.api.android.CustomPrinter.getPrinterFullStatus ( ) throws CustomException
inline

Returns the status of the printer

Returns
PrinterStatus with full status
Exceptions
CustomException
byte [] it.custom.printer.api.android.CustomPrinter.getPrinterFullStatusBuffer ( ) throws CustomException
inline

Returns the status of the printer

Returns
4 bytes full status
Exceptions
CustomException
int it.custom.printer.api.android.CustomPrinter.getPrinterId ( ) throws CustomException
inline

Returns the printer ID

Returns
Printer ID
Exceptions
CustomException
String it.custom.printer.api.android.CustomPrinter.getPrinterInfo ( )
inline

Returns information about the Printer

Returns
formation about the Printer
String it.custom.printer.api.android.CustomPrinter.getPrinterName ( )
inline

Returns name/ type of the Printer

Returns
name/ type for the Printer
long it.custom.printer.api.android.CustomPrinter.getReadTimeout ( ) throws CustomException
inline

Returns the Read Timeout

Returns
Read Timeout (milliseconds)
Exceptions
CustomException
int it.custom.printer.api.android.CustomPrinter.getResolution ( )
inline

Returns Print resolution

Returns
Print resolution
long it.custom.printer.api.android.CustomPrinter.getWriteTimeout ( ) throws CustomException
inline

Returns the Write Timeout

Returns
Write Timeout (milliseconds)
Exceptions
CustomException
boolean it.custom.printer.api.android.CustomPrinter.isPrinterOnline ( ) throws CustomException
inline

Returns if the printer is ready or not

Returns
true if printer is online else false
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.present ( int  presentMM) throws CustomException
inline

Sends a present command to the printer

Parameters
presentMMmm of paper to present
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.PrintBarcode ( String  brcText,
int  brcType,
int  brcHriType,
int  brcJustification,
int  brcWidth,
int  brcHeight 
) throws CustomException
inline

Sends barcode string to printer to print

Parameters
brcTextBarcode Text
brcTypeBarcode Type
  • BARCODE_TYPE_CODABAR - Indicates to print a CODEBAR Barcode
  • BARCODE_TYPE_UPCA - Indicates to print a UPCA Barcode
  • BARCODE_TYPE_UPCE - Indicates to print a UPCE Barcode
  • BARCODE_TYPE_EAN13 - Indicates to print a EAN13 Barcode
  • BARCODE_TYPE_EAN8 - Indicates to print a EAN8 Barcode
  • BARCODE_TYPE_CODE39 - Indicates to print a CODE39 Barcode
  • BARCODE_TYPE_ITF - Indicates to print a ITF Barcode
  • BARCODE_TYPE_CODE93 - Indicates to print a CODE93 Barcode
  • BARCODE_TYPE_CODE128 - Indicates to print a CODE128 Barcode
  • BARCODE_TYPE_CODE32 - Indicates to print a CODE32 Barcode
brcHriTypeBarcode HRI (Human Readable Information) Type
  • BARCODE_HRI_NONE - Indicates no HRI on the Barcode
  • BARCODE_HRI_TOP - Indicates HRI on TOP of the Barcode
  • BARCODE_HRI_BOTTOM - Indicates HRI on BOTTOM of the Barcode
  • BARCODE_HRI_TOPBOTTOM - Indicates HRI on TOP and BOTTOM of the Barcode
brcJustificationBarcode Justification
  • BARCODE_ALIGN_TO_LEFT - Indicates that the Barcode Justification is Left
  • BARCODE_ALIGN_TO_CENTER - Indicates that the Barcode Justification is Center
  • BARCODE_ALIGN_TO_RIGHT - Indicates that the Barcode Justification is Right
brcWidthBarcode Width expressed in dot (referred to the narrowest bar)
brcHeightBarcode Height
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.PrintBarcode ( byte[]  brcData,
int  nBytes,
int  brcType,
int  brcHriType,
int  brcJustification,
int  brcWidth,
int  brcHeight 
) throws CustomException
inline

Sends barcode data to printer to print

Parameters
brcDataBarcode Data
nBytesBarcode Data Size
brcTypeBarcode Type
  • BARCODE_TYPE_CODABAR - Indicates to print a CODEBAR Barcode
  • BARCODE_TYPE_UPCA - Indicates to print a UPCA Barcode
  • BARCODE_TYPE_UPCE - Indicates to print a UPCE Barcode
  • BARCODE_TYPE_EAN13 - Indicates to print a EAN13 Barcode
  • BARCODE_TYPE_EAN8 - Indicates to print a EAN8 Barcode
  • BARCODE_TYPE_CODE39 - Indicates to print a CODE39 Barcode
  • BARCODE_TYPE_ITF - Indicates to print a ITF Barcode
  • BARCODE_TYPE_CODE93 - Indicates to print a CODE93 Barcode
  • BARCODE_TYPE_CODE128 - Indicates to print a CODE128 Barcode
  • BARCODE_TYPE_CODE32 - Indicates to print a CODE32 Barcode
brcHriTypeBarcode HRI (Human Readable Information) Type
  • BARCODE_HRI_NONE - Indicates no HRI on the Barcode
  • BARCODE_HRI_TOP - Indicates HRI on TOP of the Barcode
  • BARCODE_HRI_BOTTOM - Indicates HRI on BOTTOM of the Barcode
  • BARCODE_HRI_TOPBOTTOM - Indicates HRI on TOP and BOTTOM of the Barcode
brcJustificationBarcode Justification
  • BARCODE_ALIGN_TO_LEFT - Indicates that the Barcode Justification is Left
  • BARCODE_ALIGN_TO_CENTER - Indicates that the Barcode Justification is Center
  • BARCODE_ALIGN_TO_RIGHT - Indicates that the Barcode Justification is Right
brcWidthBarcode Width expressed in dot (referred to the narrowest bar)
brcHeightBarcode Height
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.PrintBarcode2D ( String  brcText,
int  brcType,
int  brcJustification,
int  brcWidth 
) throws CustomException
inline

Sends barcode 2D string to printer to print

Parameters
brcTextBarcode Text
brcTypeBarcode Type
  • BARCODE_TYPE_QRCODE - Indicates to print a QRCODE Barcode 2D
  • BARCODE_TYPE_PDF417 - Indicates to print a PDF417 Barcode 2D
  • BARCODE_TYPE_DATAMATRIX - Indicates to print a DATAMATRIX Barcode 2D
  • BARCODE_TYPE_AZTEC - Indicates to print a AZTEC Barcode 2D
brcJustificationBarcode Justification
  • BARCODE_ALIGN_TO_LEFT - Indicates that the Barcode Justification is Left
  • BARCODE_ALIGN_TO_CENTER - Indicates that the Barcode Justification is Center
  • BARCODE_ALIGN_TO_RIGHT - Indicates that the Barcode Justification is Right
brcWidthBarcode external width expressed in dot
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.PrintBarcode2D ( byte[]  brcData,
int  nBytes,
int  brcType,
int  brcJustification,
int  brcWidth 
) throws CustomException
inline

Sends barcode 2D data to printer to print

Parameters
brcDataBarcode Data
nBytesBarcode Data Size
brcTypeBarcode Type
  • BARCODE_TYPE_QRCODE - Indicates to print a QRCODE Barcode 2D
  • BARCODE_TYPE_PDF417 - Indicates to print a PDF417 Barcode 2D
  • BARCODE_TYPE_DATAMATRIX - Indicates to print a DATAMATRIX Barcode 2D
  • BARCODE_TYPE_AZTEC - Indicates to print a AZTEC Barcode 2D
brcJustificationBarcode Justification
  • BARCODE_ALIGN_TO_LEFT - Indicates that the Barcode Justification is Left
  • BARCODE_ALIGN_TO_CENTER - Indicates that the Barcode Justification is Center
  • BARCODE_ALIGN_TO_RIGHT - Indicates that the Barcode Justification is Right
brcWidthBarcode external width expressed in dot
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printImage ( Bitmap  image,
int  left_align,
int  widthOption,
int  width 
) throws CustomException
inline

Sends the Bitmap data to printer to print

Parameters
imageBitmap image
left_alignthe value is > 0, the value is the align Left align in pixel. If is <= 0:
  • IMAGE_ALIGN_TO_LEFT - align the print to the left.
  • IMAGE_ALIGN_TO_CENTER - align the print to the center.
  • IMAGE_ALIGN_TO_RIGHT - align the print to the right.
widthOptionScaling options
  • IMAGE_SCALE_NONE - No scaling. Excess size will be ignored.
  • IMAGE_SCALE_TO_FIT - Scale to fit the paper width(see getPageWidth).
  • IMAGE_SCALE_TO_WIDTH - Scale the image to width given by width parameter.
widthprinted image width in pixel/dots (used only if widthOption=IMAGE_SCALE_TO_WIDTH)
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printImage ( Bitmap  image) throws CustomException
inline

Sends the Bitmap data to printer to print fit to paper width

Parameters
imageBitmap image
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printText ( String  text,
int  pixel_la,
int  pixel_w,
PrinterFont  font 
) throws CustomException
inline

Sends the text data to printer to print

Parameters
textString to print
pixel_laLeft align in pixel
pixel_wPrint area width in pixel. Pass -1 to use max available print width
fontHolds various font attributes
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printText ( String  text,
PrinterFont  font 
) throws CustomException
inline

Sends the text data to printer to print. It will print data on full page width with 0 margin

Parameters
textString to print
fontHolds various font attributes
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printText ( String  text) throws CustomException
inline

Sends the text data to printer to print. It will print data on full page width with 0 margin using the last font attributes

Parameters
textString to print
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printTextLF ( String  text,
int  pixel_la,
int  pixel_w,
PrinterFont  font 
) throws CustomException
inline

Sends the text data to printer to print and adds a LF at the end

Parameters
textString to print
pixel_laLeft align in pixel
pixel_wPrint area width in pixel. Pass -1 to use max available print width
fontHolds various font attributes
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printTextLF ( String  text,
PrinterFont  font 
) throws CustomException
inline

Sends the text data to printer to print and adds a LF at the end. It will print data on full page width with 0 margin

Parameters
textString to print
fontHolds various font attributes
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.printTextLF ( String  text) throws CustomException
inline

Sends the text data to printer to print and adds a LF at the end. It will print data on full page width with 0 margin using the last font attributes

Parameters
textString to print
Exceptions
CustomException
int [] it.custom.printer.api.android.CustomPrinter.readData ( ) throws CustomException
inline

Read Data Buffer. It will return all available data in buffer. Buffer capacity is 1024 bytes.

Returns
byte data read from printer
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.setReadTimeout ( int  msecs) throws CustomException
inline

Sets the Read Timeout. It can be between 50-30000 milliseconds.

Parameters
msecsRead Timeout (milliseconds)
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.setWriteTimeout ( int  msecs) throws CustomException
inline

Sets the Write Timeout. It can be between 50-30000 milliseconds.

Parameters
msecsWrite Timeout (milliseconds)
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.writeData ( int[]  data) throws CustomException
inline

Write Data Buffer to printer.

Parameters
dataData Buffer to Write
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.writeData ( int[]  data,
int  offset,
int  nBytes 
) throws CustomException
inline

Write Data Buffer to printer.

Parameters
dataData Buffer to Write
offsetData Buffer offset
nBytesnumber of Bytes to send to printer
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.writeData ( byte[]  data) throws CustomException
inline

Write Data Buffer to printer.

Parameters
dataData Buffer to Write
Exceptions
CustomException
void it.custom.printer.api.android.CustomPrinter.writeData ( byte[]  data,
int  offset,
int  nBytes 
) throws CustomException
inline

Write Data Buffer to printer.

Parameters
dataData Buffer to Write
offsetData Buffer offset
nBytesnumber of Bytes to send to printer
Exceptions
CustomException

Member Data Documentation

final int it.custom.printer.api.android.CustomPrinter.BARCODE_ALIGN_TO_CENTER = -1
static

Indicates that the Barcode Justification is Center

final int it.custom.printer.api.android.CustomPrinter.BARCODE_ALIGN_TO_LEFT = 0
static

Indicates that the Barcode Justification is Left

final int it.custom.printer.api.android.CustomPrinter.BARCODE_ALIGN_TO_RIGHT = -2
static

Indicates that the Barcode Justification is Right

final int it.custom.printer.api.android.CustomPrinter.BARCODE_HRI_BOTTOM = 2
static

Indicates HRI on BOTTOM of the Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_HRI_NONE = 0
static

Indicates no HRI on the Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_HRI_TOP = 1
static

Indicates HRI on TOP of the Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_HRI_TOPBOTTOM = 3
static

Indicates HRI on TOP and BOTTOM of the Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_AZTEC = -104
static

Indicates to print a AZTEC Barcode 2D

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_CODABAR = -1
static

Indicates to print a CODEBAR Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_CODE128 = -9
static

Indicates to print a CODE128 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_CODE32 = -10
static

Indicates to print a CODE32 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_CODE39 = -6
static

Indicates to print a CODE39 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_CODE93 = -8
static

Indicates to print a CODE93 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_DATAMATRIX = -103
static

Indicates to print a DATAMATRIX Barcode 2D

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_EAN13 = -4
static

Indicates to print a EAN13 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_EAN8 = -5
static

Indicates to print a EAN8 Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_ITF = -7
static

Indicates to print a ITF Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_PDF417 = -102
static

Indicates to print a PDF417 Barcode 2D

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_QRCODE = -101
static

Indicates to print a QRCODE Barcode 2D

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_UPCA = -2
static

Indicates to print a UPCA Barcode

final int it.custom.printer.api.android.CustomPrinter.BARCODE_TYPE_UPCE = -3
static

Indicates to print a UPCE Barcode

final int it.custom.printer.api.android.CustomPrinter.COMMTYPE_BLUETOOTH = 0
static

Indicates that the communication port is a BLUETOOTH

final int it.custom.printer.api.android.CustomPrinter.COMMTYPE_COM = 3
static

Indicates that the communication port is a COM/TTY

final int it.custom.printer.api.android.CustomPrinter.COMMTYPE_ETHERNET = 1
static

Indicates that the communication port is a ETHERNET / WIFI

final int it.custom.printer.api.android.CustomPrinter.COMMTYPE_USB = 2
static

Indicates that the communication port is a USB

final int it.custom.printer.api.android.CustomPrinter.CUT_PARTIAL = 1
static

Indicates to perform a Partial Cut

final int it.custom.printer.api.android.CustomPrinter.CUT_TOTAL = 0
static

Indicates to perform a Total Cut

final int it.custom.printer.api.android.CustomPrinter.EJ_EJECT = 0
static

Indicates to perform a Eject

final int it.custom.printer.api.android.CustomPrinter.EJ_RETRACT = 1
static

Indicates to perform a Retract

final int it.custom.printer.api.android.CustomPrinter.IMAGE_ALIGN_TO_CENTER = -1
static

Indicates that the Picture Justification is Center

final int it.custom.printer.api.android.CustomPrinter.IMAGE_ALIGN_TO_LEFT = 0
static

Indicates that the Picture Justification is Left

final int it.custom.printer.api.android.CustomPrinter.IMAGE_ALIGN_TO_RIGHT = -2
static

Indicates that the Picture Justification is Right

final int it.custom.printer.api.android.CustomPrinter.IMAGE_SCALE_NONE = 0
static

Indicates that the Picture will be No scaling. Excess size will be ignored

final int it.custom.printer.api.android.CustomPrinter.IMAGE_SCALE_TO_FIT = 1
static

Indicates that the Picture will be Scale to fit the paper width

final int it.custom.printer.api.android.CustomPrinter.IMAGE_SCALE_TO_WIDTH = 2
static

Indicates that the Picture will be Scale the image to width given by width parameter