Processing Java Background Bug

Please help. For some reason, I cannot set a 1000x600 image as my background. It keeps saying the dimensions are different, but I used the dimensions of the background as the app size. Please help.

import java.util.*;
public int gHeight = 1000;
public int gWidth = 600;
public TreeSet<Pig> pigs = new TreeSet<Pig>(Comparator.comparingDouble((Pig pig) -> pig.far()).reversed());
ArrayList<Bullet> trash = new ArrayList<>();
ArrayList<Pig> pigTrash = new ArrayList<>();
PImage img;
PImage imgB;
PImage imgG;
PImage imgT;
PImage bg;
PImage pigTower;
float grav = 0.2f;
ArrayList<Bullet> bulls = new ArrayList<>();
int numBull;
int cooldown = 500;
int prevF = -cooldown;
class Bullet{
  float x;
  float y;
  float xVel;
  float yVel;
  float dist;
  float size;
  float zVel;
  public Bullet(float yv, float xv){
    x = gWidth/2;
    y = 500;
    xVel = xv;
    yVel = yv;
    zVel = 0.3 ;
    dist = 0;
    size = 40;
  }
}
void settings(){
   bg = loadImage("drew.png");
size(bg.width, bg.height);
println(bg);
if (bg == null) {
  println("Background failed to load!");
}
 
}
void setup(){
  noStroke();
  img = loadImage("pig_shoot.png");
  imgB = loadImage("magic.png");
  imgG = loadImage("grass.png");
  imgT = loadImage("tower.png");
  pigTower = loadImage("pig_tower.png");
  pigs.add(new Pig(2, 1, 1000, 600, 0));
  bulls.add(new Bullet(100, 100));
}
void draw(){
  background(255,255,255);
   //image(bg, 0, 0);
  drawPiggies();
  bullet();

}

void drawPiggies(){
  for(Pig p : pigs){
    p.distance *=0.99;
    p.y+= 1;
    p.size = (float)(20/p.far());
    if(p.typ == 0){
      float dim = p.size;
      image(pigTower, (float)p.x-dim, (float)p.y-dim, dim, dim*2);
    }
      fill(204, 153, 0);
    //rect((float)p.x-dim-10, (float)p.y, dim+20, gHeight-(float)p.y);
  }
}
void keyPressed(){
  
if(numBull < 3){
  if(millis() - prevF >= cooldown){ 
    prevF = millis();
      numBull++;
      float farY = map(mouseY, gHeight, 0, -1, -12.9);
      float farX = map(mouseX, 0, gWidth, -7, 7);
      bulls.add(new Bullet(farY, farX));
  }
  }
}

void bullet(){
  
  for(Bullet b : bulls){
    b.y += b.yVel;
    b.yVel += grav;
    b.xVel *=0.98;
    b.x+= b.xVel;
    b.dist+= 0.01;
    if(b.x > 1000 || b.x < 0 || b.y > 600 || b.y < 0){
      trash.add(b);
    }
    if(b.dist < 0.5) b.dist = 0.5;
    b.size = 20/b.dist;
    image(imgB, b.x-(b.size/2), b.y-(b.size/2), b.size, b.size);
    for(Pig p : pigs){
      if(abs((float)p.far()-b.dist) < 20){
       System.out.println("Pig " + p.pigX());
       System.out.println("Bull" + b.x);
       
      float dim = p.size;
      float pigRad = dim/2;
      float bulRad = (float)b.size/2;
      float dist = sqrt((float)(((b.x-p.pigX())*(b.x-p.pigX()))+((b.y-p.pigY())*(b.y-p.pigY()))));
      double[] pigPos = p.pos();
        if(dim < 10)dim = 10;
        if(dist < pigRad + bulRad){
          System.out.println("hit");
            p.hp -= 1;
            trash.add(b);
            if(p.hp ==0){
                pigTrash.add(p);
            }
            break;
        }
    }
    
    
    }
    pigs.removeAll(pigTrash);
  }  
  
    bulls.removeAll(trash);
    numBull = bulls.size();
}

Hello @Bill_goo,

This works:

PImage bg;

void settings()
  { 
  println(pixelDensity); //What does this report?
  //pixelDensity(1); // Look this up.
    
  String urlString = "http://learningprocessing.com/code/assets/sunflower.jpg";
  bg = loadImage(urlString);
  
  if (bg == null) 
    {
    size(bg.width, bg.height);
    }
  else
    {
    println(bg.width, bg.height);
    size(bg.width, bg.height);
    }
  }

void setup()
  {
  }

void draw()
  {
  background(bg);  // See reference
  }

Reference:

Try setting this and report back:
pixelDensity(1);

It should have displayed as an image. Did it not?

:)