For creating Facebook App, we need Icons and banners for the app with defined sizes. At the time of development ,we don't concentrate on Icons and Banners design. At the starting stage we need rough Icons and Banners. If you are a java developer you can create these Icons and Banners in a minute. You can find the basic Idea of this app at http://blog.sodhanalibrary.com/2014/09/create-phonegapcordova-icons-and.html

Java Library :

For quality image scaling, I have used java-image-scaling library.

Java Program to create icons :

Replace destinationDir with your own destination directory Path
Replace appIcon with your own app icon Path
Add dimension of the Icon you want to dimensions
Run this program
Find destination path for new Icons
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import com.mortennobel.imagescaling.ResampleOp;

public class CreateFbAppIcons {
  static String destinationDir = "C:\\fbIcons";
  static String appIcon = "C:\\icon.png";
  static ArrayList<Dimension> dimensions = new ArrayList<Dimension>();
  
  public static void main(String[] args) throws IOException {
      dimensions.add(new Dimension(1024,1024));
      dimensions.add(new Dimension(16,16));
      readFile(destinationDir);
  }
  
    public static void readFile(String path) throws IOException {
        File destDir = new File(destinationDir);
        if(!destDir.exists()) {
            destDir.mkdirs();
        }
        BufferedImage appIconImg = ImageIO.read(new File(appIcon));
        for(Dimension dim : dimensions) {
            String destFilePath = destinationDir+"\\icon"+(int)dim.getWidth()+"X"+(int)dim.getHeight()+".png";
            File destFile = new File(destFilePath);
            if(!destFile.exists()) {
                  destFile.createNewFile();
            }
            System.out.println("File "+ destFile.getAbsolutePath());
            ResampleOp resampleOp = new ResampleOp((int)dim.getWidth(),(int)dim.getHeight());
            BufferedImage generatedIcon = resampleOp.filter(appIconImg, null);
            ImageIO.write(generatedIcon, "png", destFile);  
        }
    } 
  
}

Java Program to Create Banners :

Run this program
Find destination path for new Banners
If you want any banner with specific size then you can add those dimension to dimensions
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import com.mortennobel.imagescaling.ResampleOp;

public class CreateFbBanners {
  static String destinationDir = "C:\\fbIcons";
  static String appIcon = "C:\\icon.png";
  static ArrayList<Dimension> dimensions = new ArrayList<Dimension>();
  
  public static void main(String[] args) throws IOException {
      dimensions.add(new Dimension(800,150));
      dimensions.add(new Dimension(1200,627));
      dimensions.add(new Dimension(1848,682));
      dimensions.add(new Dimension(155,100));
      readFile(destinationDir);
  }
  
    public static void readFile(String path) throws IOException {
        File dir = new File(destinationDir);
        if(!dir.exists()) {
            dir.mkdirs();
        }
        BufferedImage appIconImg = ImageIO.read(new File(appIcon));
        for(Dimension dim : dimensions) {
            String destFilePath = destinationDir+"\\icon"+(int)dim.getWidth()+"X"+(int)dim.getHeight()+".png";
            File destFile = new File(destFilePath);
            if(!destFile.exists()) {
                  destFile.createNewFile();
            }
            System.out.println("File "+ destFile.getAbsolutePath());
            ImageIO.write(createScreenImage(appIconImg,(int)dim.getWidth(),(int)dim.getHeight()), "png", destFile); 
        }
    } 
    
      private static BufferedImage createScreenImage(BufferedImage appIconImg, int width, int height) throws IOException {
          int type = appIconImg.getType() == 0? BufferedImage.TYPE_INT_ARGB : appIconImg.getType();
          BufferedImage newPGScreen = new BufferedImage(width, height, type);
          Graphics2D g = newPGScreen.createGraphics();
          g.setColor(new Color(255,255,255));
          g.fillRect(0, 0, width, height);
          double minSize = 0, tw = (double)width, th = (double)height;
          if(tw < th) {
              minSize = tw;
          } else {
              minSize = th;
          }
          minSize = minSize / 4;
          ResampleOp  resampleOp = new ResampleOp((int)(minSize*2), (int)(minSize*2));
          BufferedImage resizedIcon = resampleOp.filter(appIconImg, null);
          g.drawImage(resizedIcon, (int)((tw/2) - minSize), (int)((th/2) - minSize) , null);
          g.dispose();
          return newPGScreen;
      }

}

4 comments:




  1. Wonderful information! I found amazing information on the blogs i suggest everyone to follow the links below to get download files from this website.

    gbwhatsapp apk
    acmarket apk
    freedom apk
    live nettv apk
    aptoide apk

    ReplyDelete
  2. If you are looking for the best data provider then we are providing you the best database or business directory. If you want, we can help each other in the process process or searching for sales automation tool then we can also help you here also to provide marketing automation companies.

    ReplyDelete
  3. Thanks for the detailed information about this. I would love to see more such awesome blog posts from you. Keep up the Good Work! Thats why I love Gbwhatsapp, It has a lot of awesome features.

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts