Bava Kama9: 4
הַנּוֹתֵן צֶמֶר לְצַבָּע, וְהִקְדִּיחַתּוּ יוֹרָה, נוֹתֵן לוֹ דְמֵי צַמְרוֹ. צְבָעוֹ כָאוּר, אִם הַשֶּׁבַח יוֹתֵר עַל הַיְצִיאָה, נוֹתֵן לוֹ אֶת הַיְצִיאָה; וְאִם הַיְצִיאָה יְתֵרָה עַל הַשֶּׁבַח, נוֹתֵן לוֹ אֶת הַשֶּׁבַח.  לִצְבֹּעַ לוֹ אָדֹם, וּצְבָעוֹ שָׁחוֹר; שָׁחוֹר, וּצְבָעוֹ אָדֹם — רַבִּי מֵאִיר אוֹמֵר: נוֹתֵן לוֹ דְמֵי צַמְרוֹ. רַבִּי יְהוּדָה אוֹמֵר: אִם הַשֶּׁבַח יָתֵר עַל הַיְצִיאָה, נוֹתֵן לוֹ אֶת הַיְצִיאָה; וְאִם הַיְצִיאָה יָתֵר עַל הַשֶּׁבַח, נוֹתֵן לוֹ אֶת הַשֶּׁבַח.
[If] one gives wool to a dyer, and the cauldron burns it, he pays him the value of his wool. [If] he dyes it poorly, [then] if the improvement exceeds the expense, he pays him the expense; if, however, the expense, exceeds the improvement, he pays him [for] the improvement.  [If he gave it to him] to dye red for him, and he dyes it black; [or] black, and he dyes it red —- R' Meir says: He must pay him the value of his wool. R' Yehudah says: If the improvement exceeds the expense, he pays him the expense; if, however, the expense exceeds the improvement, he pays him [for] the improvement.