परिचय
Picasso Square द्वारा विकसित एक लोकप्रिय इमेज लोडिंग लाइब्रेरी है जो इमेज डाउनलोडिंग, कैशिंग, रीसाइज़िंग और डिस्प्ले को सरल बनाती है। एक लाइन कोड में इमेज लोड होती है।
आवश्यक चरण
चरण 1: नया प्रोजेक्ट बनाएं और डिपेंडेंसी जोड़ें
Android Studio में File → New Project से नया प्रोजेक्ट बनाएं। build.gradle (Module: app) में डिपेंडेंसी जोड़ें:
dependencies {
implementation 'com.squareup.picasso:picasso:2.71828' // नवीनतम वर्जन उपयोग करें
}
चरण 2: लेआउट फ़ाइल (res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btnDownload"
android:scaleType="centerCrop" />
<Button
android:id="@+id/btnDownload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_alignParentBottom="true"
android:text="इमेज डाउनलोड करें" />
</RelativeLayout>
चरण 3: मुख्य गतिविधि (src/MainActivity.java)
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
public class MainActivity extends AppCompatActivity {
ImageView imageView;
Button btnDownload;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
btnDownload = findViewById(R.id.btnDownload);
btnDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Picasso.get() // नए वर्जन में .with(context) के बजाय .get()
.load("https://images.pexels.com/photos/1212487/pexels-photo-1212487.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260")
.placeholder(R.drawable.placeholder) // वैकल्पिक: लोडिंग प्लेसहोल्डर
.error(R.drawable.error_image) // वैकल्पिक: एरर इमेज
.resize(600, 400) // वैकल्पिक: रीसाइज़
.centerCrop() // वैकल्पिक: क्रॉप
.into(imageView);
}
});
}
}
चरण 4: मैनिफेस्ट फ़ाइल (AndroidManifest.xml)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
package="app.com.sample">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ऐप चलाएं
डिवाइस कनेक्ट करें, Run क्लिक करें। "इमेज डाउनलोड करें" दबाएं - Picasso इमेज डाउनलोड करके ImageView में दिखाएगा।

Picasso की मुख्य विशेषताएं
| फीचर | मेथड | विवरण |
|---|---|---|
| लोडिंग | .load(url) | URL, फाइल, रिसोर्स ID, Uri सपोर्ट |
| प्लेसहोल्डर | .placeholder(resId) | लोड होते समय दिखने वाली इमेज |
| एरर हैंडलिंग | .error(resId) | फेल होने पर फॉलबैक इमेज |
| रीसाइज़ | .resize(w, h) | पिक्सेल में आकार बदलें |
| क्रॉप/फिट | .centerCrop() / .fit() | स्केल टाइप नियंत्रण |
| रोटेट | .rotate(degrees) | डिग्री में घुमाएं |
| ट्रांसफॉर्मेशन | .transform() | कस्टम ट्रांसफॉर्मेशन (ब्लर, सर्कल, आदि) |
| कैश पॉलिसी | .networkPolicy() / .memoryPolicy() | कैश बिहेवियर नियंत्रण |
| कॉलबैक | .into(target, callback) | सक्सेस/एरर लिसनर |
Picasso vs Glide vs Coil
- Picasso - सरल API, ऑटो कैशिंग, कम कॉन्फ़िगरेशन।
- Glide - GIF सपोर्ट, बेहतर मेमोरी मैनेजमेंट, लाइफसाइकिल इंटीग्रेशन।
- Coil - Kotlin-first, Coroutines सपोर्ट, आधुनिक API, हल्का।
नोट: Picasso 2.71828+ में Picasso.with(context) डिप्रिकेटेड है, Picasso.get() उपयोग करें (सिंगलटन इंस्टेंस)।